From ab004f4f985d8368a6a8cbe33f5a748f7ced8192 Mon Sep 17 00:00:00 2001
From: yvan.ni <765199919@qq.com>
Date: Mon, 19 Oct 2020 09:54:29 +0800
Subject: [PATCH] 1, 商品, 活动分享的代码
---
components/share/share.js | 9 ++++++++-
components/share/share.wxml | 26 +++++++++++++++++---------
components/share/share.wxss | 9 +++++++++
packageA/pages/activity_share/activity_share.js | 1041 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------
packageA/pages/activity_share/activity_share.json | 4 +++-
packageA/pages/activity_share/activity_share.wxml | 284 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------------------------------------------------------------------------------------------------------------------------------
packageA/pages/activity_share/activity_share.wxss | 5 +----
packageA/pages/activity_share/g_filter.wxs | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
packageA/pages/goods_share/g_filter.wxs | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
packageA/pages/goods_share/goods_share.js | 797 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------
packageA/pages/goods_share/goods_share.json | 4 +++-
packageA/pages/goods_share/goods_share.wxml | 61 ++++++++++++++++++++++++++++++++++++++++++++++---------------
packageA/pages/goods_share/goods_share.wxss | 13 +++++++++++--
pages/giftpack/giftpacklist/giftpacklist.js | 19 ++++++++++++++++---
pages/index/index/index.js | 37 ++++++++++++++++++++++++++++---------
pages/index/index/index.wxml | 4 +++-
pages/user/index/index.js | 32 +++++++++++++++++++-------------
pages/user/index/index.wxml | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------
18 files changed, 2255 insertions(+), 411 deletions(-)
create mode 100644 packageA/pages/activity_share/g_filter.wxs
create mode 100644 packageA/pages/goods_share/g_filter.wxs
diff --git a/components/share/share.js b/components/share/share.js
index 81fd079..4058661 100644
--- a/components/share/share.js
+++ b/components/share/share.js
@@ -1,11 +1,18 @@
Component({
/*** 页面的初始数据***/
data: {
+ type:0,// 0默认情况发送好友和海报 1只有发送好友
},
-
methods: {
cancel() {
this.triggerEvent('cancel',{},{bubbles: true});
+ },
+ share_img(){
+ this.triggerEvent('share_img',{},{bubbles: true});
+ },
+ set_type(type){
+ this.setData({type:type})
}
+
}
})
\ No newline at end of file
diff --git a/components/share/share.wxml b/components/share/share.wxml
index c03b4a1..7e71849 100644
--- a/components/share/share.wxml
+++ b/components/share/share.wxml
@@ -1,14 +1,22 @@
-
-
-
- 发送给好友
-
-
-
- 生成海报分享
-
+
+
+
+
+
+ 生成海报分享
+
+
+
+
+
取消
diff --git a/components/share/share.wxss b/components/share/share.wxss
index 2319856..bbec228 100644
--- a/components/share/share.wxss
+++ b/components/share/share.wxss
@@ -34,6 +34,7 @@
left: 0;
top: 0;
background-color: rgba(0,0,0,.5);
+ z-index: 100;
}
.container-wrap {
background-color: white;
@@ -139,4 +140,12 @@
.slideInUp {
-webkit-animation-name: slideInUp;
animation-name: slideInUp
+}
+
+button{
+ border: none;
+}
+
+button::after {
+ border: none;
}
\ No newline at end of file
diff --git a/packageA/pages/activity_share/activity_share.js b/packageA/pages/activity_share/activity_share.js
index 0fde15f..2c1a47e 100644
--- a/packageA/pages/activity_share/activity_share.js
+++ b/packageA/pages/activity_share/activity_share.js
@@ -1,6 +1,7 @@
// packageA//pages/goods_share/goods_share.js
+var app=getApp(),oo = app.globalData.setting,os=oo,ut = require("../../../utils/util.js");
+var regeneratorRuntime = require('../../../utils/runtime.js');
Page({
-
/**
* 页面的初始数据
*/
@@ -17,106 +18,228 @@ Page({
active1: false,
// 控制佣金
active2: false,
+ url:oo.imghost,
//popup
hiddenPopup: true,
+
+ list:[],
+ is_load:0, //是否正在加载
+ is_no_data:0, //没有数据
+ is_no_more:0, //没有更多数据
+ key_str:'',
+ pattern:0, //分成的方式
+ currentPage:1, //当前的页码
+
+ canvasHidden: 1, //-- 隐藏画布 --
+ dis_switch:0, //-- 分销开关 --
+ pattern:0, //-- 分成的方式 --
+ share_hidden:1, //-- 分享的按钮隐藏 --
+ share_good:null, //--- 要分享的商品 ---
+
+ timer:0,
+ hui_active:null, //优惠活动分享
+
+ //点击活动详情的时候的响应
+ list2:[],
+ is_load2:0,
+ is_no_data2:0, //没有数据
+ is_no_more2:0, //没有更多数据
+ currentPage2:1, //页码
+ prom_goods:null, //优惠活动的条件
+
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
-
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
+ var th=this;
+ //接受有没有导购的参数
+ var first_leader=options.first_leader;
+ if(first_leader){
+ //-- user_id代过来免登陆 --
+ getApp().globalData.user_id=first_leader;
+ getApp().getUserFir();
+ }
+
+ this.requestGoodsList();
+ //-- 自定义海报 --
+ getApp().request.promiseGet("/api/weshop/goods/poster/page",{
+ data:{store_id:os.stoid, type:1, is_use:1 }
+ }).then(res=>{
+ if(res.data.code==0){
+
+ var poster_data=res.data.data.pageData[0];
+ var json_str=poster_data.jsonStr;
+
+ if(json_str){
+ var json_data=JSON.parse(json_str);
+ if(json_data.bg_img){
+
+ //-- 把图片那到本地 --
+ wx.getImageInfo({
+ src:json_data.bg_img,
+ success: function(res) {
+ var path= res.path;
+ th.setData({share_b_img:path})
+ },
+ fail: function(res) {}
+ });
+ }
+
+ th.setData({poster:json_data})
+
+ }
+ }
+ })
+
+ //获取分销的配置
+ getApp().request.promiseGet("/api/weshop/storeDistribut/get/"+oo.stoid,{}).then(res=>{
+ if(res.data.code==0){
+ th.setData({dis_switch:res.data.data.switch,pattern:res.data.data.pattern});
+ }
+ })
+
+ //获取用户设备信息,屏幕宽度
+ wx.getSystemInfo({
+ success: res => {
+ th.setData({
+ screenWidth: res.screenWidth
+ })
+ }
+ });
+
+ //-- ---秒杀和拼团都要有定时器---
+ if(!options.currentIndex || options.currentIndex<=1){
+ //设置全局定时器
+ th.data.timer=setInterval(function () {
+ th.countDown();
+ },1000);
+ }
},
/**
* 生命周期函数--监听页面显示
*/
- onShow: function () {
-
- },
-
+ onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
+ //--清理定时器--
+ clearInterval(this.timer);
},
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- // onPullDownRefresh: function () {
-
- // },
-
- /**
+ /**e
* 页面上拉触底事件的处理函数
*/
- onReachBottom: function () {
-
- },
+ onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
-
+ var th = this;
+ //礼包的转发
+ if(th.data.currentIndex==3){
+ var lbid=th.data.hui_active.lbId;
+ var url="pages/giftpack/giftpacklist/giftpacklist?lbId="+lbid+"&isBuy=1";
+ if(getApp().globalData.user_id){
+ url+="&first_leader="+getApp().globalData.user_id;
+ }
+ var img=this.data.share_img;
+ var title=th.data.hui_active.giftTitle;
+
+ var ob={
+ title:title,
+ path:url,
+ imageUrl: img,
+ };
+ th.setData({share_hidden:1});
+ return ob;
+
+ }else{
+ //---秒杀,拼团,促销---
+ var item=this.data.share_good;
+ if(item){
+ var price = item.shop_price;
+ var title= item.goods_name;
+ var img=this.data.url+item.original_img;
+ var url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + th.data.gid;
+ if(getApp().globalData.user_id){
+ url+="&first_leader="+getApp().globalData.user_id;
+ }
+ var ob={
+ title: price + "元 " +title,
+ path:url,
+ imageUrl: img,
+ };
+ th.setData({share_hidden:1,share_good:null});
+ return ob;
+ }else{
+ var url="/pages/index/index/index";
+ if(getApp().globalData.user_id){
+ url+="?first_leader="+getApp().globalData.user_id;
+ }
+ var hui_active=this.data.hui_active;
+ var title=hui_active.name;
+ if(!title) title=hui_active.main_goods_name;
+ if(!title) title=hui_active.giftTitle;
+
+ var ob={
+ title: title,
+ path:url,
+ };
+ th.setData({share_hidden:1,share_good:null});
+ return ob;
+ }
+ }
+
},
- // 点击价格排序
- sort1() {
- if(this.data.active2) {
+
+ //-- 点击tab --
+ clickTab(e) {
+ var th=this;
+ if(this.data.currentIndex!=e.target.dataset.index){
this.setData({
- active2: !this.data.active2
+ currentIndex: e.target.dataset.index,is_no_data:0,is_no_more:0,list:[],
});
- };
- this.setData({
- active1: !this.data.active1
- });
-
+ this.data.is_load=0;
+ this.data.currentPage=1;
+ this.requestGoodsList();
+ if(e.target.dataset.index<=1){
+ //设置全局定时器
+ this.data.timer=setInterval(function () {
+ th.countDown();
+ },1000);
+ }else{
+ clearInterval(this.timer);
+ }
+ }
},
- // 点击佣金排序
- sort2() {
- if(this.data.active1) {
+
+ //-- 点击促销页tab --
+ clickTab2(e) {
+ if(this.data.currentIndex2!=e.target.dataset.index){
this.setData({
- active1: !this.data.active1
+ currentIndex2: e.target.dataset.index,is_no_data:0,is_no_more:0,list:[],
});
- };
- this.setData({
- active2: !this.data.active2
- });
- },
- // 点击tab
- clickTab(e) {
- this.setData({
- currentIndex: e.target.dataset.index,
- });
- },
- // 点击促销页tab
- clickTab2(e) {
- this.setData({
- currentIndex2: e.target.dataset.index,
- });
+ this.data.is_load=0;
+ this.data.currentPage=1;
+ this.requestGoodsList();
+ }
+
},
- // 点击秒杀和拼单底部tab
- clickTab3(e) {
- this.setData({
- currentIndex3: e.target.dataset.index,
- });
+ //-- 点击秒杀和拼单底部tab,火热进行和即将开始 --
+ clickTab3(e) {
+ if(this.data.currentIndex3!=e.target.dataset.index){
+ this.setData({
+ currentIndex3: e.target.dataset.index,is_no_data:0,is_no_more:0,list:[],
+ });
+ this.data.is_load=0;
+ this.data.currentPage=1;
+ this.requestGoodsList();
+ }
},
// 关闭弹出层
closePopup() {
@@ -124,10 +247,782 @@ Page({
hiddenPopup: true
});
},
- // 显示弹出层
- showPopup() {
- this.setData({
- hiddenPopup: false
- });
+
+ //--- 显示弹出层 ---
+ showPopup(e) {
+ var th=this;
+ var index=e.currentTarget.dataset.index;
+ var hui_active=this.data.list[index];
+
+ //---搭配促销--
+ this.setData({hui_active: hui_active});
+ ////---搭配促销--
+ if(this.data.currentIndex2==2){
+ this.get_prom_goods();
+ }else{
+ //-- 获取搭配购的从商品的信息 --
+ getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + hui_active.main_goods_id,{}).then(res=>{
+ if(res.data.code==0){
+ var info=res.data.data
+ th.setData({['hui_active.ginfo']:info});
+ }
+ })
+ this.get_colloction();
+ }
+ this.setData({hiddenPopup:false});
+
+ },
+
+ get_colloction: async function(){
+ var list=null;
+ //-- 获取搭配购的从商品的信息 --
+ await app.request.promiseGet("/api/weshop/goods/getGoodsPromList/"+oo.stoid+"/"+this.data.hui_active.main_goods_id+"/2",{}).then(res=>{
+ if(res.data.code==0){
+ list=res.data.data.collocationList;
+ }
+ })
+ if(list){
+ for(var i in list){
+ await app.request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + list[i].goods_id,{}).then(res=>{
+ if(res.data.code==0){
+ var info=res.data.data
+ list[i].shop_price=info.shop_price;
+ }
+ })
+ }
+ }
+ this.setData({list2:list});//把数据弄到前台
+
+ },
+ //-- 获取优惠商品的活动 --
+ get_prom_goods:function(){
+ var list=null;
+ var th=this;
+ var prom_goods=null;
+ var hui_active=this.data.hui_active;
+
+ //-- 获取优惠活动的详情信息 --
+ app.request.promiseGet("/api/weshop/promgoodslist/getPromGoodsInfo/"+hui_active.id,{}).then(res=>{
+ if(res.data.code==0){
+ prom_goods=res.data.data;
+ th.setData({prom_goods:prom_goods});
+ }
+ })
+ //-- 指定商品参与,才有商品列表分 --
+ if(hui_active.good_object==1){
+ this.request_prom_goods();
+ }
+
+ },
+
+ //-- -------获取商品列表--------
+ requestGoodsList:function(){
+ var th=this;
+ if(th.data.is_load) return false; //-- 正在加载
+ if(th.data.is_no_data) return false; //-- 没有数据
+ if(th.data.is_no_more) return false; //-- 没有更多
+ th.data.is_load=1;
+ var url="";
+ var req_data={
+ page:this.data.currentPage,
+ store_id:oo.stoid,
+ }
+
+ switch(th.data.currentIndex){
+ case 0: //--秒杀--
+ url="/api/ms/flash_sale/spikepage";
+ if(th.data.currentIndex3==0){
+ url+="?timetype=1"; //火热进行中
+ }else{
+ url+="?timetype=0"; //即将开始
+ }
+ req_data.is_show=1;
+ req_data.is_end=0;
+
+ if(th.data.key_str && th.data.key_str.trim()){
+ req_data.key_str=th.data.key_str.trim();
+ }
+ break;
+ case 1: //--拼团--
+ url="/api/weshop/teamlist/pageteam";
+ if(th.data.currentIndex3==0){
+ url+="/1"; //火热进行中
+ }else{
+ url+="/0"; //即将开始
+ }
+ req_data.is_show=1;
+ req_data.is_end=0;
+
+ if(th.data.key_str && th.data.key_str.trim()){
+ req_data.key_str=th.data.key_str.trim();
+ }
+ break;
+ case 2: //--促销--
+ if(th.data.currentIndex2==0){
+ url="//api/weshop/promorder/page";
+ if(th.data.key_str && th.data.key_str.trim()){
+ req_data.name=th.data.key_str.trim();
+ }
+ }else if(th.data.currentIndex2==1){
+ url="/api/weshop/prom/collocation/pageCollocationGoods";
+ if(th.data.key_str && th.data.key_str.trim()){
+ req_data.name=th.data.key_str.trim();
+ }
+ }else{
+ url="/api/weshop/promgoods/page";
+ if(th.data.key_str && th.data.key_str.trim()){
+ req_data.name=th.data.key_str.trim();
+ }
+ }
+ break;
+ case 3: //专享礼包
+ url='/api/weshop/marketing/giftbag/pageMd';
+ if(th.data.key_str && th.data.key_str.trim()){
+ req_data.key_str=th.data.key_str.trim();
+ }
+ break;
+ }
+
+ if(this.data.key_str && this.data.key_str.trim()){
+ var str=this.data.key_str.trim();
+ req_data.key_str=str;
+ }
+ //-- ---调用接口----
+ app.request.promiseGet(url,{data:req_data,isShowLoading:1}).then(res=>{
+ th.data.is_load=0;
+ if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){
+ th.data.currentPage++;
+ var data=res.data.data.pageData;
+ if(res.data.data.page*10>res.data.data.total){th.setData({is_no_more:1});}
+ var list=th.data.list;
+ list=list.concat(data);
+ th.setData({list:list});
+ }else{
+ if(th.data.currentPage==1){
+ th.setData({is_no_data:1});
+ }
+ }
+ })
+ },
+
+ //-- -------获取活动详情的商品的列表--------
+ request_prom_goods:function(){
+ var th=this;
+ if(th.data.is_load2) return false; //-- 正在加载
+ if(th.data.is_no_data2) return false; //-- 没有数据
+ if(th.data.is_no_more2) return false; //-- 没有更多
+ th.data.is_load2=1;
+
+ var req_data={
+ page:th.data.currentPage2
+ }
+ app.request.promiseGet("/api/weshop/goods/page?store_id="+oo.stoid+"&prom_type=3&prom_id="+th.data.hui_active.id,{
+ data:req_data,isShowLoading:1
+ }).then(res=>{
+ th.data.is_load2=0;
+ if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){
+ th.data.currentPage2++;
+ var data=res.data.data.pageData;
+ if(res.data.data.page*10>res.data.data.total){th.setData({is_no_more2:1});}
+ var list=th.data.list2;
+ list=list.concat(data);
+ th.setData({list2:list});
+ }else{
+ if(th.data.currentPage==1){
+ th.setData({is_no_data2:1});
+ }
+ }
+ })
+ },
+
+ //--- 获取卡类列表 ---
+ getPlusCardType: function (func) {
+ var storid = oo.stoid;
+ var th = this;
+ getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => {
+ var plusCard = res.data.data;
+ var arr = [1219, 2089, 3031];
+ var new_arr = new Array();
+ var card_name_map=new Map();
+ var user = getApp().globalData.userInfo;
+ for (var i = 0; i < plusCard.length; i++) {
+ if ((user.card_field==null || user.card_field=="") && (plusCard[i].IsStopBuy==true)) {
+ continue;
+ }
+ var name="card"+plusCard[i].CorrPrice.toLowerCase();
+ card_name_map.set(name,plusCard[i].CardName);
+ new_arr.push(plusCard[i]);
+ }
+
+ var ob={"card_list":new_arr,"name_map":card_name_map};
+ func(ob);
+ })
+ },
+
+
+ //---图片失败,默认图片---
+ bind_bnerr2: function (e) {
+ var _errImg = e.target.dataset.errorimg;
+ var _errObj = {};
+ _errObj[_errImg] ="/miniapp/images/default_g_img.gif";
+ this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
+ },
+ //-- ---更多加载----
+ refresh:function(){
+ this.requestGoodsList();
+ },
+
+ //--定义的保存图片方法,分享团---
+ saveImageToPhotosAlbum: function() {
+ //--先判断会员状态--
+ var user_info = getApp().globalData.userInfo;
+ if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
+ //getApp().my_warnning("请先登录",0,this);
+ wx.navigateTo({ url: '/pages/togoin/togoin', })
+ return false;
+ }
+ //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团
+ var type = 0;
+ wx.showLoading({
+ title: '生成中...',
+ })
+ var that = this, th = that;
+ //设置画板显示,才能开始绘图,并关闭底部按钮
+ that.setData({
+ canvasHidden: false,share_hidden:1
+ })
+
+ var app = getApp();
+ var unit = that.data.screenWidth / 750 * 1.35; //基础单位,
+ var scene = th.data.gid+"";
+ var user_id=getApp().globalData.user_id?getApp().globalData.user_id:0;
+ if(user_id>0){
+ scene+="_"+user_id;
+ }
+
+ ///二微码
+ var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" +
+ os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo";
+
+ //读取文件成功则OK--
+ wx.getImageInfo({
+ src: path3,
+ success: function(res) {
+ //回调写法
+ th.get_head_temp(th.get_goods_temp, function() {
+ var vpath = res.path;
+ var context = wx.createCanvasContext('share');
+ //先画背景
+ var pg_path = "../../../images/share/share_bg.png";
+
+ //-- 如果有自定义海报的时候,判断背景的图片 --
+ if(th.data.share_b_img){
+ pg_path=th.data.share_b_img;
+ }
+ context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit);
+
+ //-- 是自定义海报的情况下 --
+ if(th.data.poster && parseInt(th.data.poster.style)==2){
+ //在线上分享人的情况下
+ if(parseInt(th.data.poster.show_headpic)){
+ //获取坐标
+ var x=parseFloat(th.data.poster.head_x)*2;
+ var y=parseFloat(th.data.poster.head_y)*2;
+ var x1=(x+90) *unit;
+ var y1=(y+50) *unit;
+ //--昵称---
+ context.setFontSize(24 * unit)
+ context.setFillStyle("black")
+ context.fillText(app.globalData.userInfo.nickname, x1, y1);
+ var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit;
+ //强烈推荐 改许程
+ var tj_path = "../../../images/share/q_tj.png";
+ context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit);
+ context.setFontSize(16 * unit)
+ context.setLineJoin('round'); //交点设置成圆角
+ context.setFillStyle("white")
+ context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit);
+ }
+ }else{
+ //--昵称---
+ context.setFontSize(24 * unit)
+ context.setFillStyle("black")
+ context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit);
+ var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit;
+ //强烈推荐 改许程
+ var tj_path = "../../../images/share/q_tj.png";
+ context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit);
+ context.setFontSize(16 * unit)
+ context.setLineJoin('round'); //交点设置成圆角
+ context.setFillStyle("white")
+ context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 76 * unit);
+ }
+
+
+ //---产品名称---
+ //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
+ context.setFillStyle("black");
+ context.setFontSize(21.3 * unit)
+ th.draw_Text(context, th.data.share_good.goods_name,
+ 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit);
+ //------产品的价格-------
+ context.setFontSize(23 * unit)
+ context.setFillStyle("red")
+ context.fillText("¥", 416 * unit, 185 * unit);
+ context.setFontSize(31 * unit)
+ var pri0 = th.data.share_good.shop_price;
+ if (th.data.prom_act)
+ pri0 = th.data.prom_act.price;
+
+ pri0 = parseFloat(pri0).toFixed(2);
+ context.fillText(pri0, 438 * unit, 185 * unit);
+ //---市场价划掉---
+ context.setFillStyle("gray")
+ context.setFontSize(22 * unit)
+ context.fillText("¥" + th.data.share_good.market_price, 426 * unit, 213 * unit);
+ context.setStrokeStyle('gray')
+ context.setLineWidth(1 * unit)
+ context.moveTo(426 * unit, 206 * unit)
+ context.lineTo(510 * unit, 206 * unit)
+ context.stroke();
+ //---中间大图---
+ context.drawImage(th.data.share_goods_img, 68 * unit, 242 * unit, 410 * unit, 410 * unit);
+ //-------大图后面就不一样了-----------
+ switch (type) {
+ case 0: //普通商品的展示
+ //中间的几个字
+ if(th.data.poster && parseInt(th.data.poster.style)==2 ){
+ if(parseInt(th.data.poster.show_quality)){
+ var g_path = "../../../images/share/s_gou.png";
+ context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
+ context.setFillStyle("red")
+ context.setFontSize(18 * unit)
+ context.fillText("正品保证", 84 * unit, 690 * unit);
+
+ context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
+ context.setFillStyle("red")
+ context.setFontSize(18 * unit)
+ context.fillText("纯实体店", 246 * unit, 690 * unit);
+
+ context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
+ context.setFillStyle("red")
+ context.setFontSize(18 * unit)
+ context.fillText("官方验证", 420 * unit, 690 * unit);
+ }
+
+ }else{
+ var g_path = "../../../images/share/s_gou.png";
+ context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
+ context.setFillStyle("red")
+ context.setFontSize(18 * unit)
+ context.fillText("正品保证", 84 * unit, 690 * unit);
+
+ context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
+ context.setFillStyle("red")
+ context.setFontSize(18 * unit)
+ context.fillText("纯实体店", 246 * unit, 690 * unit);
+
+ context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
+ context.setFillStyle("red")
+ context.setFontSize(18 * unit)
+ context.fillText("官方验证", 420 * unit, 690 * unit);
+ }
+
+ //---画线---
+ context.setLineWidth(1 * unit)
+ context.moveTo(32 * unit, 710 * unit)
+ context.lineTo(520 * unit, 710 * unit)
+ context.stroke();
+ //---文字---
+ context.setFillStyle("black")
+ context.setFontSize(22 * unit)
+ // 原来start --->
+ context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 776 * unit);
+ context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 826 * unit);
+
+ //---二维吗图---
+ //-- 自定义海报 --
+ if(th.data.poster){
+ var erm_x= parseFloat(th.data.poster.ewm_x)*2;
+ var erm_y= parseFloat(th.data.poster.ewm_y)*2;
+ context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
+ }else{
+ //---二维吗图---
+ context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
+ }
+
+ break;
+ case 1: //秒杀商品的展示
+ //---画线---
+ context.setLineWidth(1 * unit)
+ context.moveTo(32 * unit, 670 * unit)
+ context.lineTo(520 * unit, 670 * unit)
+ context.stroke();
+
+ //画秒杀的图片
+ var miaos_path = '../../../images/share/miao_share.png';
+ context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit);
+
+ //---文字---
+ context.setFontSize(22 * unit)
+ context.setFillStyle("black")
+ context.fillText("特惠好物,限时秒杀", 40 * unit, 806 * unit);
+ context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit);
+ //---二维吗图---
+ //-- 自定义海报 --
+ if(th.data.poster){
+ var erm_x= parseFloat(th.data.poster.ewm_x)*2;
+ var erm_y= parseFloat(th.data.poster.ewm_y)*2;
+ context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
+ }else{
+ //---二维吗图---
+ context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
+ }
+ break;
+
+ case 2: //会员团和商家团的展示
+ //---画线---
+ context.setLineWidth(1 * unit)
+ context.moveTo(32 * unit, 670 * unit)
+ context.lineTo(520 * unit, 670 * unit)
+ context.stroke();
+ //---文字---
+ context.setFontSize(22 * unit)
+ context.font = 'normal bold';
+ context.setFillStyle("black")
+ context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit);
+
+ //绘制成团图片
+ var ct_img = "../../../images/share/ct_num.png";
+ context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit);
+ var ct_num = th.data.prom_act.ct_num;
+ context.setFontSize(14 * unit)
+ context.font = 'normal';
+ context.setFillStyle("red")
+ if (ct_num < 10) {
+ context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit);
+ } else {
+ context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit);
+ }
+ context.setFontSize(22 * unit)
+ context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit);
+ context.setFillStyle("gray")
+ context.fillText("快来和我一起拼团吧!", 40 * unit, 826 * unit);
+ context.setFillStyle("black")
+ context.font = 'normal bold 18px sans-serif';
+ context.setFontSize(21.3 * unit)
+ context.fillText("长按识别二维码,立即参团", 40 * unit, 856 * unit);
+ //---二维吗图---
+ //-- 自定义海报 --
+ if(th.data.poster){
+ var erm_x= parseFloat(th.data.poster.ewm_x)*2;
+ var erm_y= parseFloat(th.data.poster.ewm_y)*2;
+ context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
+ }else{
+ //---二维吗图---
+ context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
+ }
+ break
+ case 3: //阶梯团的展示
+ //---画线---
+ context.setLineWidth(1 * unit)
+ context.moveTo(32 * unit, 670 * unit)
+ context.lineTo(520 * unit, 670 * unit)
+ context.stroke();
+ //---文字---
+ context.setFontSize(22 * unit)
+ context.font = 'normal bold';
+ context.setFillStyle("black")
+ context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit);
+ //---绘制中间阶梯的价格---
+ var list = th.data.prom_act.ct_rylist;
+ for (var i = 0; i < list.length; i++) {
+ var item = list[i];
+ var wi = i * 90 * unit;
+ context.font = 'normal';
+ context.setFontSize(16 * unit)
+ context.setFillStyle("red")
+ context.fillText("¥", 40 * unit + wi, 756 * unit);
+ context.setFontSize(22 * unit)
+ var pri = parseFloat(item.price).toFixed(2);
+ context.fillText(pri, 56 * unit + wi, 756 * unit);
+ context.setFillStyle("gray")
+ context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit);
+ }
+ //----------------下面部分----------------
+ context.setFillStyle("gray")
+ context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit);
+ context.setFillStyle("black")
+ context.font = 'normal bold 18px sans-serif';
+ context.setFontSize(22 * unit)
+ context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit);
+
+ //-- 自定义海报 --
+ if(th.data.poster){
+ var erm_x= parseFloat(th.data.poster.ewm_x)*2;
+ var erm_y= parseFloat(th.data.poster.ewm_y)*2;
+ context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
+ }else{
+ //---二维吗图---
+ context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
+ }
+ break
+ }
+
+
+ //--- 如果是自定义海报的时候 ---
+ if(th.data.poster && parseInt(th.data.poster.style)==2){
+ //如果显示会员信息的话
+ if(parseInt(th.data.poster.show_headpic)){
+ //获取坐标
+ var x= parseFloat(th.data.poster.head_x)*2;
+ var y=parseFloat(th.data.poster.head_y)*2;
+ //---绘制圆形要放在最后----
+ context.save();
+ context.beginPath();
+ var h_x = x* unit;
+ var h_y = y * unit;
+ var h_r = 40 * unit;
+ var cx = h_x + h_r;
+ var cy = h_y + h_r;
+ context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
+ context.closePath();
+ context.fill();
+ context.clip();
+ context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
+ context.restore();
+ }
+
+ }else{
+ //---绘制圆形要放在最后----
+ context.save();
+ context.beginPath();
+ var h_x = 60 * unit;
+ var h_y = 24 * unit;
+ var h_r = 40 * unit;
+ var cx = h_x + h_r;
+ var cy = h_y + h_r;
+ context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
+ context.closePath();
+ context.fill();
+ context.clip();
+ context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
+ context.restore();
+ }
+
+
+ //把画板内容绘制成图片,并回调 画板图片路径
+ context.draw(false, function() {
+ setTimeout(function() {
+ wx.canvasToTempFilePath({
+ x: 0,
+ y: 0,
+ width: 750,
+ height: 1217,
+ destWidth: 1.2 * 750 * 750 / that.data.screenWidth,
+ destHeight: 1.2 * 1217 * 750 / that.data.screenWidth,
+ canvasId: 'share',
+ success: function(res) {
+ that.setData({
+ shareImgPath: res.tempFilePath,
+ canvasHidden: true
+ })
+ if (!res.tempFilePath) {
+ wx.showModal({
+ title: '提示',
+ content: '图片绘制中,请稍后重试',
+ showCancel: false
+ })
+ return false;
+ }
+ wx.previewImage({
+ //将图片预览出来
+ urls: [that.data.shareImgPath]
+ });
+ //-- 将商品清空 --
+ th.setData({share_good:null});
+
+ wx.hideLoading();
+ }
+ })
+ }, 500)
+
+ });
+ });
+ }
+ });
+
+ },
+ //---点击分享优惠活动---
+ share_index:function(e){
+ var index=e.currentTarget.dataset.index;
+ var item=this.data.list[index];
+ this.setData({share_hidden:0,hui_active:item});
+
+ var com = this.selectComponent("#share_button"); //组件的id
+ com.set_type(1);
+ },
+ //---点击分享商品---
+ share_good:function(e){
+ var index=e.currentTarget.dataset.index;
+ var item=this.data.list[index];
+ this.setData({share_hidden:0,share_good:item});
+
+ var com = this.selectComponent("#share_button"); //组件的id
+ com.set_type(0);
+ },
+
+ //----活动详情里面的分享---
+ share_good2:function(e){
+ var index=e.currentTarget.dataset.index;
+ var item=this.data.list2[index];
+ this.setData({share_hidden:0,share_good:item});
+ var com = this.selectComponent("#share_button"); //组件的id
+ com.set_type(0);
+ },
+
+ //-----详情里面的分享-------
+ share_detail:function(e){
+ var com = this.selectComponent("#share_button"); //组件的id
+ com.set_type(0);
+
+ var idx=e.currentTarget.dataset.index;
+ var item=this.data.list2[index];
+ this.setData({share_hidden:0,share_good:item});
+ },
+
+ cancel:function(){
+ this.setData({share_hidden:1});
+ },
+
+ //--获取头像的本地缓存,回调写法--
+ get_head_temp: function(tt, func) {
+ var ee = this;
+ if (ee.data.share_head) {
+ tt(func);
+ return false;
+ }
+ //---获取分享图片的本地地址,头像和商品图片----
+ var path2 = getApp().globalData.userInfo.head_pic;
+ if (path2 == "") {
+ ee.data.share_head = "../../../images/share/hui_hear_pic.png";
+ tt(func);
+ } else {
+ path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
+ path2 = path2.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
+ wx.getImageInfo({
+ src: path2,
+ success: function(res) {
+ //res.path是网络图片的本地地址
+ ee.data.share_head = res.path;
+ tt(func);
+ },
+ fail: function(res) {
+ ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的
+ tt(func);
+ }
+ });
+ }
+ },
+ //--获取商品图片的本地缓存,回调写法--
+ get_goods_temp: function(tt) {
+ var ee = this;
+ //获取商品是分享图信息
+ wx.getImageInfo({
+ src: ee.data.url+ee.data.share_good.original_img,
+ success: function(res) {
+ //res.path是网络图片的本地地址
+ ee.data.share_goods_img = res.path;
+ tt();
+ },
+ fail: function(res) {
+ ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的
+ tt();
+ }
+ });
+ },
+
+ //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
+ draw_Text: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) {
+ var lineWidth = 0;
+ var lastSubStrIndex = 0; //每次开始截取的字符串的索引
+ var han = 0;
+ for (let i = 0; i < str.length; i++) {
+ if (han == 2) return;
+ //lineWidth += ctx.measureText(str[i]).width;
+ lineWidth += ut.measureText(str[i], 21.3 * unit);
+ if (lineWidth > canvasWidth) {
+ han++;
+
+ if (han == 2)
+ ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分
+ else
+ ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight);
+
+ initHeight += 22; //22为字体的高度
+ lineWidth = 0;
+ lastSubStrIndex = i;
+ titleHeight += 20;
+ }
+ if (i == str.length - 1) { //绘制剩余部分
+ ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight);
+ }
+ }
+ },
+
+ //---小于10的格式化函数----
+ timeFormat(param) {
+ return param < 10 ? '0' + param : param;
},
+
+ //----倒计时函数-----
+ countDown() {
+ if(!this.data.timer) return false;
+ var th=this;
+ // 获取当前时间,同时得到活动结束时间数组
+ let newTime =ut.gettimestamp();
+ var endTimeList = this.data.list;
+ if(endTimeList==null) return null
+ // 对结束时间进行处理渲染到页面
+ for (var i = 0; i < endTimeList.length;i++){
+ var o = endTimeList[i];
+ var endTime = o.end_time;
+ let obj = null;
+ // 如果活动未结束,对时间进行处理
+ if (endTime - newTime > 0){
+ let time = (endTime - newTime);
+ // 获取天、时、分、秒
+ let day = parseInt(time / (60 * 60 * 24));
+ let hou = parseInt(time % (60 * 60 * 24) / 3600);
+ let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
+ let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
+ obj = {
+ day: this.timeFormat(day), hou: this.timeFormat(hou), min: this.timeFormat(min), sec: this.timeFormat(sec), hide: 1
+ }
+ }else{
+ //活动已结束,全部设置为'00'
+ obj = { day: '00', hou: '00', min: '00', sec: '00' }
+ }
+ var txt ="list["+i+"].djs";
+ th.setData({ [txt]: obj});
+ }
+ },
+
+ //-------搜索的相关功能------
+ set_search_value:function(e){
+ var key_str=e.detail.value;
+ if(key_str) key_str=key_str.trim();
+ this.setData({key_str:key_str});
+
+ },
+ search_data:function(){
+ this.setData({
+ is_no_data:0,is_no_more:0,list:[],
+ });
+ this.data.is_load=0;
+ this.data.currentPage=1;
+ this.requestGoodsList();
+ }
+
+
})
\ No newline at end of file
diff --git a/packageA/pages/activity_share/activity_share.json b/packageA/pages/activity_share/activity_share.json
index 0ad7ff9..1c34554 100644
--- a/packageA/pages/activity_share/activity_share.json
+++ b/packageA/pages/activity_share/activity_share.json
@@ -1,6 +1,8 @@
{
+ "navigationBarTitleText": "活动分享",
"usingComponents": {
- "nodata": "/components/nodata/nodata"
+ "nodata": "/components/nodata/nodata",
+ "share_button": "/components/share/share"
},
"enablePullDownRefresh": false
}
\ No newline at end of file
diff --git a/packageA/pages/activity_share/activity_share.wxml b/packageA/pages/activity_share/activity_share.wxml
index 214fe44..7fe123b 100644
--- a/packageA/pages/activity_share/activity_share.wxml
+++ b/packageA/pages/activity_share/activity_share.wxml
@@ -1,8 +1,9 @@
+
-
- 搜索
+
+ 搜索
@@ -23,40 +24,50 @@
-
-
- 暂无数据
-
+
+
+
-
+
+
+
+
- 商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称
+ {{item.title}}
-
- 剩余100%
+
+ 剩余{{g_filter.toFix(100*(item.goods_num-item.buy_num)/item.goods_num,2) }}%
- 已抢0件
+ 已抢{{item.buy_num}}件
- 已拼0份
+ 已拼{{item.buy_num}}份
1人团
- 剩余:51天21时37分34秒
+ 剩余:
+ {{item.djs.day}}天
+ {{item.djs.hou}}时
+ {{item.djs.min}}分
+ {{item.djs.sec}}秒
+
- ¥200.00
- 零售价:¥76.00
+ ¥{{item.price}}
+ 零售价:¥{{item.market_price}}
- 分享
+ 分享
@@ -68,21 +79,26 @@
- 折
- 促销活动名称名称名称名称名称名称名称名称名称名称
+ 折
+ 减
+ 配
+ 惠
+ {{item.main_goods_name}}
+ {{item.name}}
- 促销时间:2020-09-28 16:00 到 2020-09-28 16:00
+ 促销时间:{{g_filter.format_time(item.start_time,1)}} 到 {{g_filter.format_time(item.end_time,1)}}
-
+
- 需购买金额:¥400
- 折扣:90
+ 需购买金额:¥{{g_filter.toFix(item.money,2)}}
+ 折扣:{{item.expression}}(%)
+ 优惠金额:{{g_filter.toFix(item.expression,2)}}
- 分享
+ 分享
-
- 活动详情
- 分享
+
+ 活动详情
+ 分享
@@ -92,18 +108,29 @@
-
+
+
+
- 商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称
- ¥200.00/10积分
- 零售价:¥76.00
- 已售:3
- 分享
+ {{item.giftTitle}}
+
+ ¥{{g_filter.toFix(item.payMoney,2)}}
+ /
+ {{item.payIntegral}}积分
+
+ 零售价:¥{{item.giftPosPrice}}
+
+ 分享
- - 已全部加载 -
+
+
+ 暂无数据
+ - 已全部加载 -
@@ -126,9 +153,9 @@
-
-
-
+
+
+
@@ -140,77 +167,35 @@
搭配价
+
- 全部商品
- 指定商品
+
+
+
+ 全部商品
+
+
+
+
+ 指定商品
+
@@ -219,75 +204,48 @@
手店价
操作
-
-
- 1
- 欧式满护手霜手霜手霜手霜手霜手霜
- ¥50/¥40
- 分享
-
-
- 1
- 欧式满护手霜手霜手霜手霜手霜手霜
- ¥50/¥40
- 分享
-
-
- 1
- 欧式满护手霜手霜手霜手霜手霜手霜
- ¥50/¥40
- 分享
-
-
- 1
- 欧式满护手霜手霜手霜手霜手霜手霜
- ¥50/¥40
- 分享
-
-
- 1
- 欧式满护手霜手霜手霜手霜手霜手霜
- ¥50/¥40
- 分享
-
-
- 1
- 欧式满护手霜手霜手霜手霜手霜手霜
- ¥50/¥40
- 分享
-
-
- 1
- 欧式满护手霜手霜手霜手霜手霜手霜
- ¥50/¥40
- 分享
-
-
- 1
- 欧式满护手霜手霜手霜手霜手霜手霜
- ¥50/¥40
- 分享
-
+
+
+
+ {{index+1}}
+ {{item.goods_name}}
+ ¥{{item.shop_price}}
+ 分享
+
+
-
- 需购买:50元/件
-
-
- 减现金 -100
- 打折 90%
-
-
- 包邮
- 积分 90
+
+
+ 需购买:{{item.condition}}
+ 元
+ 件
- 优惠券
- 赠品
- 礼包
-
+
+
+ 减现金 -{{item.money}}
+ 打折 {{item.sale}}%
+
+
+ 包邮
+
+
+ 积分 {{item.intValue}}
+
+
+ 积分
+
+
+
+ 优惠券
+ 赠品
+ 礼包
+
+
+
@@ -297,3 +255,7 @@
+
+
+
+
diff --git a/packageA/pages/activity_share/activity_share.wxss b/packageA/pages/activity_share/activity_share.wxss
index f186123..25bedb9 100644
--- a/packageA/pages/activity_share/activity_share.wxss
+++ b/packageA/pages/activity_share/activity_share.wxss
@@ -111,10 +111,7 @@ page {
justify-content: center;
}
.img-container:after {
- font-family: iconfont;
- content: '\e8c1';
- color: #bbb;
- font-size: 80rpx;
+
}
.details {
flex: 1;
diff --git a/packageA/pages/activity_share/g_filter.wxs b/packageA/pages/activity_share/g_filter.wxs
new file mode 100644
index 0000000..1b39749
--- /dev/null
+++ b/packageA/pages/activity_share/g_filter.wxs
@@ -0,0 +1,114 @@
+var g_filters = {
+ //-- 判断是不是有等级价 --
+ is_has_rank:function(rank_switch,item){
+ if(!rank_switch) return false;
+ if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true}
+ return false;
+ },
+
+ //-- 判断,不是等级会员时候,要显示的最低等级价和名称 --
+ get_card_price:function(goods,all_card,type){
+ var price1=parseFloat(goods['cardprice1']);
+ var price2=parseFloat(goods['cardprice2']);
+ var price3=parseFloat(goods['cardprice3']);
+ if(!all_card){
+ if(type==0) return 0;
+ return "";
+ }
+
+ var arr=[];
+ var min_price= 0;
+ var min_name="";
+
+ var min_price=null;
+ var min_name=null;
+ //---设置对应的价格名字----
+ for(var i=0;i<3;i++) {
+ var vl=all_card[i];
+ if(!vl) continue;
+ if(vl['CorrPrice']=="Price1" && price1>0)
+ {
+ if(min_price==null) {
+ min_price=price1;min_name=vl['CardName'];
+ }
+ else if(price10)
+ {
+ if(min_price==null) {
+ min_price=price2;min_name=vl['CardName'];
+ }
+ else if(price20)
+ {
+ if(min_price==null) {
+ min_price=price3;min_name=vl['CardName'];
+ }
+ else if(price34) min_name=min_name.substring(0, 8);
+ return min_name;
+ },
+
+ toFix: function (val, count) {
+ val = parseFloat(val);
+ return val.toFixed(count)
+ },
+ format_time: function (ts, isFull) {
+ // 如果数值位数为1,则补0
+ function appendZero(obj) {
+ if (obj < 10) {
+ return "0" + "" + obj;
+ } else {
+ return obj;
+ }
+ };
+
+ if (ts == null || ts == undefined || ts == '') return "";
+ var d = getDate(ts * 1000)
+ var fm = [d.getFullYear(), d.getMonth() + 1, d.getDate()].join('-');
+ var md = (d.getMonth() + 1) + '月' + d.getDate() + '日';
+ if (isFull == 1)
+ fm = fm + ' ' + [d.getHours(), d.getMinutes(), d.getSeconds()].join(':');
+ if (isFull == 2) {
+ fm = md + ' ' + [appendZero(d.getHours()), appendZero(d.getMinutes())].join(':');
+ }
+ return fm;
+ },
+
+}
+module.exports = {
+ is_has_rank:g_filters.is_has_rank,
+ get_card_price:g_filters.get_card_price,
+ toFix:g_filters.toFix,
+ format_time:g_filters.format_time,
+}
\ No newline at end of file
diff --git a/packageA/pages/goods_share/g_filter.wxs b/packageA/pages/goods_share/g_filter.wxs
new file mode 100644
index 0000000..9b68b2e
--- /dev/null
+++ b/packageA/pages/goods_share/g_filter.wxs
@@ -0,0 +1,85 @@
+var g_filters = {
+ //-- 判断是不是有等级价 --
+ is_has_rank:function(rank_switch,item){
+ if(!rank_switch) return false;
+ if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true}
+ return false;
+ },
+
+ //-- 判断,不是等级会员时候,要显示的最低等级价和名称 --
+ get_card_price:function(goods,all_card,type){
+ var price1=parseFloat(goods['cardprice1']);
+ var price2=parseFloat(goods['cardprice2']);
+ var price3=parseFloat(goods['cardprice3']);
+ if(!all_card){
+ if(type==0) return 0;
+ return "";
+ }
+
+ var arr=[];
+ var min_price= 0;
+ var min_name="";
+
+ var min_price=null;
+ var min_name=null;
+ //---设置对应的价格名字----
+ for(var i=0;i<3;i++) {
+ var vl=all_card[i];
+ if(!vl) continue;
+ if(vl['CorrPrice']=="Price1" && price1>0)
+ {
+ if(min_price==null) {
+ min_price=price1;min_name=vl['CardName'];
+ }
+ else if(price10)
+ {
+ if(min_price==null) {
+ min_price=price2;min_name=vl['CardName'];
+ }
+ else if(price20)
+ {
+ if(min_price==null) {
+ min_price=price3;min_name=vl['CardName'];
+ }
+ else if(price34) min_name=min_name.substring(0, 8);
+ return min_name;
+ },
+}
+module.exports = {
+ is_has_rank:g_filters.is_has_rank,
+ get_card_price:g_filters.get_card_price,
+}
\ No newline at end of file
diff --git a/packageA/pages/goods_share/goods_share.js b/packageA/pages/goods_share/goods_share.js
index 564968b..2f68a3b 100644
--- a/packageA/pages/goods_share/goods_share.js
+++ b/packageA/pages/goods_share/goods_share.js
@@ -1,6 +1,6 @@
// packageA//pages/goods_share/goods_share.js
+var app=getApp(),oo = app.globalData.setting,os=oo,ut = require("../../../utils/util.js");
Page({
-
/**
* 页面的初始数据
*/
@@ -9,62 +9,145 @@ Page({
active1: false,
// 控制佣金
active2: false,
+ url:oo.imghost,
+ orderField:'sales_sum',
+ orderType:'desc',
+ list:[],
+ is_load:0, //是否正在加载
+ is_no_data:0, //没有数据
+ is_no_more:0, //没有更多数据
+ key_str:'',
+ pattern:0, //分成的方式
+ currentPage:1, //当前的页码
+
+ canvasHidden: 1, //-- 隐藏画布 --
+ dis_switch:0, //-- 分销开关 --
+ pattern:0, //-- 分成的方式 --
+ share_hidden:1, //-- 分享的按钮隐藏 --
+ share_good:null //--- 要分享的商品 ---
},
-
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
-
+ var th=this;
+ //接受有没有导购的参数
+ var first_leader=options.first_leader;
+ if(first_leader){
+ //-- user_id代过来免登陆 --
+ getApp().globalData.user_id=first_leader;
+ getApp().getUserFir();
+ }
+ this.requestGoodsList();
+
+ //-- 自定义海报 --
+ getApp().request.promiseGet("/api/weshop/goods/poster/page",{
+ data:{store_id:os.stoid, type:1, is_use:1 }
+ }).then(res=>{
+ if(res.data.code==0){
+
+ var poster_data=res.data.data.pageData[0];
+ var json_str=poster_data.jsonStr;
+
+ if(json_str){
+ var json_data=JSON.parse(json_str);
+ if(json_data.bg_img){
+
+ //-- 把图片那到本地 --
+ wx.getImageInfo({
+ src:json_data.bg_img,
+ success: function(res) {
+ var path= res.path;
+ th.setData({share_b_img:path})
+ },
+ fail: function(res) {}
+ });
+ }
+
+ th.setData({poster:json_data})
+
+ }
+ }
+ })
+
+ //获取分销的配置
+ getApp().request.promiseGet("/api/weshop/storeDistribut/get/"+oo.stoid,{}).then(res=>{
+ if(res.data.code==0){
+ th.setData({dis_switch:res.data.data.switch,pattern:res.data.data.pattern});
+ }
+ })
+ //获取用户设备信息,屏幕宽度
+ wx.getSystemInfo({
+ success: res => {
+ th.setData({
+ screenWidth: res.screenWidth
+ })
+ }
+ });
+
},
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
+ /*** 生命周期函数--监听页面显示***/
onShow: function () {
-
+ var th=this;
+ getApp().getConfig2(function(rs){
+ //计算等级价相关
+ var swithc_list=rs.switch_list;
+ var sw_arr=JSON.parse(swithc_list);
+ //---如果后台又开等级卡的开关---
+ if(sw_arr.rank_switch && sw_arr.rank_switch=="2"){
+ th.setData({rank_switch:true});
+ var user=getApp().globalData.userInfo;
+ var ti=setInterval(function(){
+ if(!user) return false;
+ clearInterval(ti);
+ //---回调卡的列表---
+ th.getPlusCardType(function(ob){
+ th.setData({card_list:ob.card_list});
+ if(user.card_field ){
+ var str = user['card_expiredate'].replace(/-/g, '/');
+ var end = new Date(str);
+ end = Date.parse(end) / 1000;
+ var now = ut.gettimestamp();
+ //--- 判断是等级会员,且在有效期范围内 ---
+ if(user.card_field && now4) card_name=card_name.substring(0,4);
+ th.setData({card_field:user.card_field,card_name:card_name,card_list:ob.card_list});
+ }
+ }
+ })
+ },500)
+ }
+ });
},
/**
* 生命周期函数--监听页面隐藏
*/
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- // onPullDownRefresh: function () {
-
- // },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
+ onHide: function () {},
+ /**e
* 用户点击右上角分享
*/
onShareAppMessage: function () {
-
+ var th = this;
+ var item=this.data.share_good;
+ var price = item.shop_price;
+ var title= item.goods_name;
+ var img=this.data.url+item.original_img;
+
+ var url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + th.data.gid;
+ if(getApp().globalData.user_id){
+ url+="&first_leader="+getApp().globalData.user_id;
+ }
+ var ob={
+ title: price + "元 " +title,
+ path:url,
+ imageUrl: img,
+ };
+ th.setData({share_hidden:1});
+ return ob;
+
},
// 点击价格排序
@@ -73,11 +156,22 @@ Page({
this.setData({
active2: !this.data.active2
});
- };
- this.setData({
- active1: !this.data.active1
- });
-
+ };
+ if(this.data.orderField!="shop_price"){
+ this.setData({
+ active1: 1,orderField:'shop_price',orderType:'asc',is_no_data:0,is_no_more:0,list:[],
+ });
+ }else{
+
+ var ty=this.data.orderType=='asc'?'desc':'asc';
+ this.setData({
+ orderType:ty,is_no_data:0,is_no_more:0,list:[],
+ });
+ }
+ this.data.is_load=0;
+ this.data.currentPage=1;
+ this.requestGoodsList();
+
},
// 点击佣金排序
sort2() {
@@ -85,9 +179,612 @@ Page({
this.setData({
active1: !this.data.active1
});
- };
- this.setData({
- active2: !this.data.active2
- });
+ };
+ if(this.data.orderField!="commission"){
+
+ if(this.data.pattern==0){
+ this.setData({
+ active2: 1,orderField:'commission',orderType:'asc',is_no_data:0,is_no_more:0,list:[],
+ });
+ }else{
+ this.setData({
+ active2: 1,orderField:'(fir_rate+sec_rate+thi_rate)',orderType:'asc',is_no_data:0,is_no_more:0,list:[],
+ });
+ }
+
+
+ }else{
+ this.setData({
+ orderType: (this.data.orderType=='asc'?'desc':'asc'),is_no_data:0,is_no_more:0,list:[],
+ });
+ }
+ this.data.is_load=0;
+ this.data.currentPage=1;
+ this.requestGoodsList();
},
+
+ //-- ----销量----
+ sale_sort(){
+ if(this.data.orderField!="sales_sum"){
+ this.setData({
+ active1: 0,active2:0,orderType:'desc',is_no_data:0,is_no_more:0,orderField:'sales_sum',list:[],
+ });
+ this.data.is_load=0;
+ this.data.currentPage=1;
+ this.requestGoodsList();
+ }
+ },
+
+ //-- ---最新---
+ new_sort:function(){
+ if(this.data.orderField!="is_new"){
+ this.setData({
+ active1: 0,active2:0,orderType:'desc',is_no_data:0,is_no_more:0,orderField:'is_new',list:[],
+ });
+ this.data.is_load=0;
+ this.data.currentPage=1;
+ this.requestGoodsList();
+ }
+ },
+
+ requestGoodsList:function(){
+ var th=this;
+ if(th.data.is_load) return false; //-- 正在加载
+ if(th.data.is_no_data) return false; //-- 没有数据
+ if(th.data.is_no_more) return false; //-- 没有更多
+ th.data.is_load=1;
+
+ var url="/api/weshop/goods/page";
+ var req_data={
+ page:this.data.currentPage,
+ is_mainshow:1,
+ isonsale:1,
+ store_id:oo.stoid,
+ orderField:this.data.orderField,
+ orderType:this.data.orderType,
+ }
+ if(this.data.key_str && this.data.key_str.trim()){
+ var str=this.data.key_str.trim();
+ req_data.key_str=str;
+ }
+ //-- ---调用接口----
+ app.request.promiseGet(url,{data:req_data,isShowLoading:1}).then(res=>{
+ th.data.is_load=0;
+ if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){
+ th.data.currentPage++;
+ var data=res.data.data.pageData;
+ if(res.data.data.page*10>res.data.data.total){th.setData({is_no_more:1});}
+ var list=th.data.list;
+ list=list.concat(data);
+ th.setData({list:list});
+ }else{
+ if(th.data.currentPage==1){
+ th.setData({is_no_data:1});
+ }
+ }
+ })
+ },
+
+
+ //--- 获取卡类列表 ---
+ getPlusCardType: function (func) {
+ var storid = oo.stoid;
+ var th = this;
+ getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => {
+ var plusCard = res.data.data;
+ var arr = [1219, 2089, 3031];
+ var new_arr = new Array();
+ var card_name_map=new Map();
+ var user = getApp().globalData.userInfo;
+ for (var i = 0; i < plusCard.length; i++) {
+ if ((user.card_field==null || user.card_field=="") && (plusCard[i].IsStopBuy==true)) {
+ continue;
+ }
+ var name="card"+plusCard[i].CorrPrice.toLowerCase();
+ card_name_map.set(name,plusCard[i].CardName);
+ new_arr.push(plusCard[i]);
+ }
+
+ var ob={"card_list":new_arr,"name_map":card_name_map};
+ func(ob);
+ })
+ },
+
+
+ //---图片失败,默认图片---
+ bind_bnerr2: function (e) {
+ var _errImg = e.target.dataset.errorimg;
+ var _errObj = {};
+ _errObj[_errImg] ="/miniapp/images/default_g_img.gif";
+ this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
+ },
+ //-- ---更多加载----
+ refresh:function(){
+ this.requestGoodsList();
+ },
+
+ //--定义的保存图片方法,分享团---
+ saveImageToPhotosAlbum: function() {
+ //--先判断会员状态--
+ var user_info = getApp().globalData.userInfo;
+ if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
+ //getApp().my_warnning("请先登录",0,this);
+ wx.navigateTo({ url: '/pages/togoin/togoin', })
+ return false;
+ }
+ //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团
+ var type = 0;
+ wx.showLoading({
+ title: '生成中...',
+ })
+ var that = this, th = that;
+ //设置画板显示,才能开始绘图
+ that.setData({
+ canvasHidden: false,share_hidden:1
+ })
+
+ var app = getApp();
+ var unit = that.data.screenWidth / 750 * 1.35; //基础单位,
+ var scene = th.data.gid+"";
+ var user_id=getApp().globalData.user_id?getApp().globalData.user_id:0;
+ if(user_id>0){
+ scene+="_"+user_id;
+ }
+
+ ///二微码
+ var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" +
+ os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo";
+
+ //读取文件成功则OK--
+ wx.getImageInfo({
+ src: path3,
+ success: function(res) {
+ //回调写法
+ th.get_head_temp(th.get_goods_temp, function() {
+ var vpath = res.path;
+ var context = wx.createCanvasContext('share');
+ //先画背景
+ var pg_path = "../../../images/share/share_bg.png";
+
+ //-- 如果有自定义海报的时候,判断背景的图片 --
+ if(th.data.share_b_img){
+ pg_path=th.data.share_b_img;
+ }
+ context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit);
+
+ //-- 是自定义海报的情况下 --
+ if(th.data.poster && parseInt(th.data.poster.style)==2){
+ //在线上分享人的情况下
+ if(parseInt(th.data.poster.show_headpic)){
+ //获取坐标
+ var x=parseFloat(th.data.poster.head_x)*2;
+ var y=parseFloat(th.data.poster.head_y)*2;
+ var x1=(x+90) *unit;
+ var y1=(y+50) *unit;
+ //--昵称---
+ context.setFontSize(24 * unit)
+ context.setFillStyle("black")
+ context.fillText(app.globalData.userInfo.nickname, x1, y1);
+ var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit;
+ //强烈推荐 改许程
+ var tj_path = "../../../images/share/q_tj.png";
+ context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit);
+ context.setFontSize(16 * unit)
+ context.setLineJoin('round'); //交点设置成圆角
+ context.setFillStyle("white")
+ context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit);
+ }
+ }else{
+ //--昵称---
+ context.setFontSize(24 * unit)
+ context.setFillStyle("black")
+ context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit);
+ var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit;
+ //强烈推荐 改许程
+ var tj_path = "../../../images/share/q_tj.png";
+ context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit);
+ context.setFontSize(16 * unit)
+ context.setLineJoin('round'); //交点设置成圆角
+ context.setFillStyle("white")
+ context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 76 * unit);
+ }
+
+
+ //---产品名称---
+ //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
+ context.setFillStyle("black");
+ context.setFontSize(21.3 * unit)
+ th.draw_Text(context, th.data.share_good.goods_name,
+ 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit);
+ //------产品的价格-------
+ context.setFontSize(23 * unit)
+ context.setFillStyle("red")
+ context.fillText("¥", 416 * unit, 185 * unit);
+ context.setFontSize(31 * unit)
+ var pri0 = th.data.share_good.shop_price;
+ if (th.data.prom_act)
+ pri0 = th.data.prom_act.price;
+
+ pri0 = parseFloat(pri0).toFixed(2);
+ context.fillText(pri0, 438 * unit, 185 * unit);
+ //---市场价划掉---
+ context.setFillStyle("gray")
+ context.setFontSize(22 * unit)
+ context.fillText("¥" + th.data.share_good.market_price, 426 * unit, 213 * unit);
+ context.setStrokeStyle('gray')
+ context.setLineWidth(1 * unit)
+ context.moveTo(426 * unit, 206 * unit)
+ context.lineTo(510 * unit, 206 * unit)
+ context.stroke();
+ //---中间大图---
+ context.drawImage(th.data.share_goods_img, 68 * unit, 242 * unit, 410 * unit, 410 * unit);
+ //-------大图后面就不一样了-----------
+ switch (type) {
+ case 0: //普通商品的展示
+ //中间的几个字
+ if(th.data.poster && parseInt(th.data.poster.style)==2 ){
+ if(parseInt(th.data.poster.show_quality)){
+ var g_path = "../../../images/share/s_gou.png";
+ context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
+ context.setFillStyle("red")
+ context.setFontSize(18 * unit)
+ context.fillText("正品保证", 84 * unit, 690 * unit);
+
+ context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
+ context.setFillStyle("red")
+ context.setFontSize(18 * unit)
+ context.fillText("纯实体店", 246 * unit, 690 * unit);
+
+ context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
+ context.setFillStyle("red")
+ context.setFontSize(18 * unit)
+ context.fillText("官方验证", 420 * unit, 690 * unit);
+ }
+
+ }else{
+ var g_path = "../../../images/share/s_gou.png";
+ context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
+ context.setFillStyle("red")
+ context.setFontSize(18 * unit)
+ context.fillText("正品保证", 84 * unit, 690 * unit);
+
+ context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
+ context.setFillStyle("red")
+ context.setFontSize(18 * unit)
+ context.fillText("纯实体店", 246 * unit, 690 * unit);
+
+ context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
+ context.setFillStyle("red")
+ context.setFontSize(18 * unit)
+ context.fillText("官方验证", 420 * unit, 690 * unit);
+ }
+
+ //---画线---
+ context.setLineWidth(1 * unit)
+ context.moveTo(32 * unit, 710 * unit)
+ context.lineTo(520 * unit, 710 * unit)
+ context.stroke();
+ //---文字---
+ context.setFillStyle("black")
+ context.setFontSize(22 * unit)
+ // 原来start --->
+ context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 776 * unit);
+ context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 826 * unit);
+
+ //---二维吗图---
+ //-- 自定义海报 --
+ if(th.data.poster){
+ var erm_x= parseFloat(th.data.poster.ewm_x)*2;
+ var erm_y= parseFloat(th.data.poster.ewm_y)*2;
+ context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
+ }else{
+ //---二维吗图---
+ context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
+ }
+
+ break;
+ case 1: //秒杀商品的展示
+ //---画线---
+ context.setLineWidth(1 * unit)
+ context.moveTo(32 * unit, 670 * unit)
+ context.lineTo(520 * unit, 670 * unit)
+ context.stroke();
+
+ //画秒杀的图片
+ var miaos_path = '../../../images/share/miao_share.png';
+ context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit);
+
+ //---文字---
+ context.setFontSize(22 * unit)
+ context.setFillStyle("black")
+ context.fillText("特惠好物,限时秒杀", 40 * unit, 806 * unit);
+ context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit);
+ //---二维吗图---
+ //-- 自定义海报 --
+ if(th.data.poster){
+ var erm_x= parseFloat(th.data.poster.ewm_x)*2;
+ var erm_y= parseFloat(th.data.poster.ewm_y)*2;
+ context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
+ }else{
+ //---二维吗图---
+ context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
+ }
+
+
+ break;
+
+ case 2: //会员团和商家团的展示
+ //---画线---
+ context.setLineWidth(1 * unit)
+ context.moveTo(32 * unit, 670 * unit)
+ context.lineTo(520 * unit, 670 * unit)
+ context.stroke();
+ //---文字---
+ context.setFontSize(22 * unit)
+ context.font = 'normal bold';
+ context.setFillStyle("black")
+ context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit);
+
+ //绘制成团图片
+ var ct_img = "../../../images/share/ct_num.png";
+ context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit);
+ var ct_num = th.data.prom_act.ct_num;
+ context.setFontSize(14 * unit)
+ context.font = 'normal';
+ context.setFillStyle("red")
+ if (ct_num < 10) {
+ context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit);
+ } else {
+ context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit);
+ }
+ context.setFontSize(22 * unit)
+ context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit);
+ context.setFillStyle("gray")
+ context.fillText("快来和我一起拼团吧!", 40 * unit, 826 * unit);
+ context.setFillStyle("black")
+ context.font = 'normal bold 18px sans-serif';
+ context.setFontSize(21.3 * unit)
+ context.fillText("长按识别二维码,立即参团", 40 * unit, 856 * unit);
+ //---二维吗图---
+ //-- 自定义海报 --
+ if(th.data.poster){
+ var erm_x= parseFloat(th.data.poster.ewm_x)*2;
+ var erm_y= parseFloat(th.data.poster.ewm_y)*2;
+ context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
+ }else{
+ //---二维吗图---
+ context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
+ }
+ break
+ case 3: //阶梯团的展示
+ //---画线---
+ context.setLineWidth(1 * unit)
+ context.moveTo(32 * unit, 670 * unit)
+ context.lineTo(520 * unit, 670 * unit)
+ context.stroke();
+ //---文字---
+ context.setFontSize(22 * unit)
+ context.font = 'normal bold';
+ context.setFillStyle("black")
+ context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit);
+ //---绘制中间阶梯的价格---
+ var list = th.data.prom_act.ct_rylist;
+ for (var i = 0; i < list.length; i++) {
+ var item = list[i];
+ var wi = i * 90 * unit;
+ context.font = 'normal';
+ context.setFontSize(16 * unit)
+ context.setFillStyle("red")
+ context.fillText("¥", 40 * unit + wi, 756 * unit);
+ context.setFontSize(22 * unit)
+ var pri = parseFloat(item.price).toFixed(2);
+ context.fillText(pri, 56 * unit + wi, 756 * unit);
+ context.setFillStyle("gray")
+ context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit);
+ }
+ //----------------下面部分----------------
+ context.setFillStyle("gray")
+ context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit);
+ context.setFillStyle("black")
+ context.font = 'normal bold 18px sans-serif';
+ context.setFontSize(22 * unit)
+ context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit);
+
+ //-- 自定义海报 --
+ if(th.data.poster){
+ var erm_x= parseFloat(th.data.poster.ewm_x)*2;
+ var erm_y= parseFloat(th.data.poster.ewm_y)*2;
+ context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
+ }else{
+ //---二维吗图---
+ context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
+ }
+ break
+ }
+
+
+ //--- 如果是自定义海报的时候 ---
+ if(th.data.poster && parseInt(th.data.poster.style)==2){
+ //如果显示会员信息的话
+ if(parseInt(th.data.poster.show_headpic)){
+ //获取坐标
+ var x= parseFloat(th.data.poster.head_x)*2;
+ var y=parseFloat(th.data.poster.head_y)*2;
+ //---绘制圆形要放在最后----
+ context.save();
+ context.beginPath();
+ var h_x = x* unit;
+ var h_y = y * unit;
+ var h_r = 40 * unit;
+ var cx = h_x + h_r;
+ var cy = h_y + h_r;
+ context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
+ context.closePath();
+ context.fill();
+ context.clip();
+ context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
+ context.restore();
+ }
+
+ }else{
+ //---绘制圆形要放在最后----
+ context.save();
+ context.beginPath();
+ var h_x = 60 * unit;
+ var h_y = 24 * unit;
+ var h_r = 40 * unit;
+ var cx = h_x + h_r;
+ var cy = h_y + h_r;
+ context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
+ context.closePath();
+ context.fill();
+ context.clip();
+ context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
+ context.restore();
+ }
+
+
+ //把画板内容绘制成图片,并回调 画板图片路径
+ context.draw(false, function() {
+ setTimeout(function() {
+ wx.canvasToTempFilePath({
+ x: 0,
+ y: 0,
+ width: 750,
+ height: 1217,
+ destWidth: 1.2 * 750 * 750 / that.data.screenWidth,
+ destHeight: 1.2 * 1217 * 750 / that.data.screenWidth,
+ canvasId: 'share',
+ success: function(res) {
+ that.setData({
+ shareImgPath: res.tempFilePath,
+ canvasHidden: true
+ })
+ if (!res.tempFilePath) {
+ wx.showModal({
+ title: '提示',
+ content: '图片绘制中,请稍后重试',
+ showCancel: false
+ })
+ return false;
+ }
+ wx.previewImage({
+ //将图片预览出来
+ urls: [that.data.shareImgPath]
+ });
+ wx.hideLoading();
+ }
+ })
+ }, 500)
+
+ });
+ });
+ }
+ });
+
+ },
+
+ //点击分享商品
+ share_good:function(e){
+ var index=e.currentTarget.dataset.index;
+ var item=this.data.list[index];
+ this.setData({share_hidden:0,share_good:item});
+ },
+
+ cancel:function(){
+ this.setData({share_hidden:1});
+ },
+
+ //--获取头像的本地缓存,回调写法--
+ get_head_temp: function(tt, func) {
+ var ee = this;
+ if (ee.data.share_head) {
+ tt(func);
+ return false;
+ }
+ //---获取分享图片的本地地址,头像和商品图片----
+ var path2 = getApp().globalData.userInfo.head_pic;
+ if (path2 == "") {
+ ee.data.share_head = "../../../images/share/hui_hear_pic.png";
+ tt(func);
+ } else {
+ path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
+ path2 = path2.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
+ wx.getImageInfo({
+ src: path2,
+ success: function(res) {
+ //res.path是网络图片的本地地址
+ ee.data.share_head = res.path;
+ tt(func);
+ },
+ fail: function(res) {
+ ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的
+ tt(func);
+ }
+ });
+ }
+ },
+ //--获取商品图片的本地缓存,回调写法--
+ get_goods_temp: function(tt) {
+ var ee = this;
+ //获取商品是分享图信息
+ wx.getImageInfo({
+ src: ee.data.url+ee.data.share_good.original_img,
+ success: function(res) {
+ //res.path是网络图片的本地地址
+ ee.data.share_goods_img = res.path;
+ tt();
+ },
+ fail: function(res) {
+ ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的
+ tt();
+ }
+ });
+ },
+
+ //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
+ draw_Text: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) {
+ var lineWidth = 0;
+ var lastSubStrIndex = 0; //每次开始截取的字符串的索引
+ var han = 0;
+ for (let i = 0; i < str.length; i++) {
+ if (han == 2) return;
+ //lineWidth += ctx.measureText(str[i]).width;
+ lineWidth += ut.measureText(str[i], 21.3 * unit);
+ if (lineWidth > canvasWidth) {
+ han++;
+
+ if (han == 2)
+ ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分
+ else
+ ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight);
+
+ initHeight += 22; //22为字体的高度
+ lineWidth = 0;
+ lastSubStrIndex = i;
+ titleHeight += 20;
+ }
+ if (i == str.length - 1) { //绘制剩余部分
+ ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight);
+ }
+ }
+ },
+
+ //-------搜索的相关功能------
+ set_search_value:function(e){
+ var key_str=e.detail.value;
+ if(key_str) key_str=key_str.trim();
+ this.setData({key_str:key_str});
+
+ },
+ search_data:function(){
+ this.setData({
+ is_no_data:0,is_no_more:0,list:[],
+ });
+ this.data.is_load=0;
+ this.data.currentPage=1;
+ this.requestGoodsList();
+ }
+
+
})
\ No newline at end of file
diff --git a/packageA/pages/goods_share/goods_share.json b/packageA/pages/goods_share/goods_share.json
index 0ad7ff9..e1c41f0 100644
--- a/packageA/pages/goods_share/goods_share.json
+++ b/packageA/pages/goods_share/goods_share.json
@@ -1,6 +1,8 @@
{
+ "navigationBarTitleText": "商品分享",
"usingComponents": {
- "nodata": "/components/nodata/nodata"
+ "nodata": "/components/nodata/nodata",
+ "share_button": "/components/share/share"
},
"enablePullDownRefresh": false
}
\ No newline at end of file
diff --git a/packageA/pages/goods_share/goods_share.wxml b/packageA/pages/goods_share/goods_share.wxml
index 86e304b..d922e98 100644
--- a/packageA/pages/goods_share/goods_share.wxml
+++ b/packageA/pages/goods_share/goods_share.wxml
@@ -1,38 +1,69 @@
+
-
- 搜索
+
+ 搜索
- 销量
- 价格
- 佣金
- 最新
+ 销量
+ 价格
+ 佣金
+ 最新
- 暂无数据
+ refresher-enabled>
+
-
+
+
+
- 商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称
- ¥200.00
+ {{item.goods_name}}
+ ¥{{item.shop_price}}
+
+
+
+
+ PLUS¥{{item[card_field]}}
+
+
+
+ PLUS¥{{g_filter.get_card_price(item,card_list,0)}}
+
+
+
+
- 已售:3
- 分成金额:¥21
+ 已售:{{item.sales_sum}}
+ 分成金额:
+ ¥{{item.commission}}
+ ¥{{item.fir_rate+item.sec_rate+item.thi_rate}}
+
+
+
+ 分享
- 分享
- - 已全部加载 -
+
+ 暂无数据
+ - 已全部加载 -
+
+
+
+
+
diff --git a/packageA/pages/goods_share/goods_share.wxss b/packageA/pages/goods_share/goods_share.wxss
index b228d1e..d88b837 100644
--- a/packageA/pages/goods_share/goods_share.wxss
+++ b/packageA/pages/goods_share/goods_share.wxss
@@ -74,10 +74,10 @@ page {
justify-content: center;
}
.img-container:after {
- font-family: iconfont;
+ /* font-family: iconfont;
content: '\e8c1';
color: #bbb;
- font-size: 80rpx;
+ font-size: 80rpx; */
}
.details {
flex: 1;
@@ -107,3 +107,12 @@ page {
.name {
height: 76rpx;
}
+
+.plus_show{
+ background-color: #FE6867;
+ color: #fff;
+ padding: 3rpx 5rpx;
+ border-radius:8rpx ;
+ margin-left: 10rpx;
+ margin-right: 5rpx;
+}
diff --git a/pages/giftpack/giftpacklist/giftpacklist.js b/pages/giftpack/giftpacklist/giftpacklist.js
index ab300ff..b62bef0 100644
--- a/pages/giftpack/giftpacklist/giftpacklist.js
+++ b/pages/giftpack/giftpacklist/giftpacklist.js
@@ -37,18 +37,31 @@ Page({
getGiftID: options.lbId,
orderSn: options.orderSn
})
+
+ //-- 获取分享人的ID --
+ var first_leader=options.first_leader;
+ if(first_leader){
+ //-- user_id代过来免登陆 --
+ getApp().globalData.user_id=first_leader;
+ getApp().getUserFir();
+ //调用接口判断是不是会员
+ getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+oo.stoid+"/"+first_leader,{}).then(res=>{
+ if(res.data.code==0){
+ getApp().globalData.guide_id=res.data.data.id;
+ }
+ })
+ }
th.close();
},
- onShow: function() {
-
+
+ onShow: function() {
//--先判断会员状态--
var user_info = getApp().globalData.userInfo;
if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
getApp().goto('/pages/togoin/togoin');
return false;
}
-
if (this.data.isBuy == 0) {
this.GetMyGiftList();
} else {
diff --git a/pages/index/index/index.js b/pages/index/index/index.js
index 1a2b376..cebe2ea 100644
--- a/pages/index/index/index.js
+++ b/pages/index/index/index.js
@@ -72,14 +72,26 @@ Page({
max_sw_height: 0, //banner的最大高度
is_disgraceful: 0, //是否显示新人广告
new_image: "", //新人有礼弹窗图片
- new_nav: "", //新人页面跳转地址
-
- w_holiday_pop:0,
-
- },
-
- onLoad: async function() {
- var th = this;
+ new_nav: "", //新人页面跳转地址
+ w_holiday_pop:0,
+
+ },
+
+ onLoad: async function(tt) {
+ var th = this;
+ var first_leader=tt.first_leader;
+ if(first_leader){
+ //-- user_id代过来免登陆 --
+ getApp().globalData.user_id=first_leader;
+ getApp().getUserFir();
+ //调用接口判断是不是会员
+ getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+oo.stoid+"/"+first_leader,{}).then(res=>{
+ if(res.data.code==0){
+ getApp().globalData.guide_id=res.data.data.id;
+ }
+ })
+ }
+
//看一下商家是否开通了权益
//--初始化是否有打勾--
getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", {
@@ -859,7 +871,14 @@ Page({
if(!url || url=='') return;
if(url[0]!='/') url='/'+url;
getApp().goto(url);
- }
+ },
+
+ //----跳转到搭配购买----
+ go_test:function () {
+ wx.navigateTo({ url: "/packageA/pages/goods_share/goods_share", })
+ },
+
+
diff --git a/pages/index/index/index.wxml b/pages/index/index/index.wxml
index 22bf8b5..8c0a1c7 100644
--- a/pages/index/index/index.wxml
+++ b/pages/index/index/index.wxml
@@ -3,6 +3,8 @@
+
+
@@ -84,7 +86,7 @@
- 人工优先
+ 人工优先
diff --git a/pages/user/index/index.js b/pages/user/index/index.js
index e26c997..428b8c0 100644
--- a/pages/user/index/index.js
+++ b/pages/user/index/index.js
@@ -57,24 +57,30 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
- onLoad: function(options) {
+ onLoad: function(options) {
var th=this;
+ //-- 读取会员中心按钮列表 --
+ getApp().request.promiseGet("/api/weshop/userTool/page", {
+ }).then(res => {
+ if(res.data.code==0 ){
+ var d_list=res.data.data.pageData;
+ th.setData({user_tool:d_list});
+ }
+ })
this.birthday();
- getApp().request.promiseGet("/api/weshop/ad/list?pid=401&store_id=" + os.stoid, {
+ getApp().request.promiseGet("/api/weshop/ad/page?pid=401&store_id=" + os.stoid, {
data: {
enabled: 1
}
}).then(res => {
if(res.data.code==0 && res.data.data){
- var item=res.data.data[0];
- if (item && item.ad_code)
+ var item=res.data.data.pageData[0];
+ if (item && item.ad_code)
th.setData({ad_img:item.ad_code})
}
- })
-
+ })
app.getUserFir();
-
-
+
},
/**
@@ -122,9 +128,7 @@ Page({
}
}
});
-
-
-
+
/*-----统计-----*/
rq.get("/api/weshop/order/waitlist", {
data: {
@@ -298,8 +302,10 @@ Page({
getApp().getConfig2(function(e) {
var t_swi = e.switch_list;
if (t_swi) t_swi = JSON.parse(t_swi)
- if(t_swi){
- th.setData({sys_switch:t_swi})
+ if(t_swi){
+ var user_tool=[];
+ if(t_swi.usertool) user_tool=JSON.parse(t_swi.usertool);
+ th.setData({sys_switch:t_swi,c_list:user_tool});
}
diff --git a/pages/user/index/index.wxml b/pages/user/index/index.wxml
index 9264d59..374537d 100644
--- a/pages/user/index/index.wxml
+++ b/pages/user/index/index.wxml
@@ -1,6 +1,6 @@
-
+
@@ -199,73 +199,59 @@
-
-
- 我的拼单
-
-
-
- 秒杀活动
-
-
-
- 我的权益
-
-
-
-
-
-
- 联系客服
-
-
-
-
-
-
-
- plus会员
-
-
-
-
- 收藏夹
-
-
-
-
- 我的评价
-
-
-
-
- 我的地址
-
-
-
-
-
- 收入卡包
-
-
-
-
- 我的服务
-
-
-
- 专享礼包
-
-
-
-
- 助力活动
-
-
-
+
+
+
+
+
+
+
+
+
+ PLUS会员
+
+
+
+
+
+ 助力活动
+
+
+
+
+
+ {{item.name}}
+
+
+
+
+
+
+
+
+ 我的权益
+
+
+
+
+
+
+ 联系客服
+
+
+
+
+
+
+ 收入卡包
+
+
+
+
+
--
libgit2 0.21.4