Commit 1dfbcf3bc0a69f29843469884e4da4702931dff8

Authored by taiyuan
1 parent 529162f2

服务分享

packageA/pages/service_share/g_filter.wxs 0 → 100644
  1 +var g_filters = {
  2 + //-- 判断是不是有等级价 --
  3 + is_has_rank:function(rank_switch,item){
  4 + if(!rank_switch) return false;
  5 + if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true}
  6 + return false;
  7 + },
  8 +
  9 + //-- 判断,不是等级会员时候,要显示的最低等级价和名称 --
  10 + get_card_price:function(goods,all_card,type){
  11 + var price1=parseFloat(goods['cardprice1']);
  12 + var price2=parseFloat(goods['cardprice2']);
  13 + var price3=parseFloat(goods['cardprice3']);
  14 + if(!all_card){
  15 + if(type==0) return 0;
  16 + return "";
  17 + }
  18 +
  19 + var arr=[];
  20 + var min_price= 0;
  21 + var min_name="";
  22 +
  23 + var min_price=null;
  24 + var min_name=null;
  25 + //---设置对应的价格名字----
  26 + for(var i=0;i<3;i++) {
  27 + var vl=all_card[i];
  28 + if(!vl) continue;
  29 + if(vl['CorrPrice']=="Price1" && price1>0)
  30 + {
  31 + if(min_price==null) {
  32 + min_price=price1;min_name=vl['CardName'];
  33 + }
  34 + else if(price1<min_price) {
  35 + min_price=price1;min_name=vl['CardName'];
  36 + }
  37 + }
  38 + if(vl['CorrPrice']=="Price2" && price2>0)
  39 + {
  40 + if(min_price==null) {
  41 + min_price=price2;min_name=vl['CardName'];
  42 + }
  43 + else if(price2<min_price) {
  44 + min_price=price2;min_name=vl['CardName'];
  45 + }
  46 + }
  47 +
  48 + if(vl['CorrPrice']=="Price3" && price3>0)
  49 + {
  50 + if(min_price==null) {
  51 + min_price=price3;min_name=vl['CardName'];
  52 + }
  53 + else if(price3<min_price) {
  54 + min_price=price3;min_name=vl['CardName'];
  55 + }
  56 + }
  57 +
  58 + }
  59 + if(min_price==null){
  60 + if(type==0) return 0;
  61 + return "";
  62 + }
  63 +
  64 + //if(type==0) return arr.length;
  65 + //--进行排序,升序---
  66 + /*---
  67 + arr.sort(function(a,b){
  68 + if (a.price < b.price) {
  69 + return -1;
  70 + } else if (a.fee == b.fee) {
  71 + return 0;
  72 + } else {
  73 + return 1;
  74 + }
  75 + })--*/
  76 + //-- 获取最下价钱,和相应的卡的名称 --
  77 + if(type==0) return min_price.toFixed(2);
  78 + if(min_name.length>4) min_name=min_name.substring(0, 8);
  79 + return min_name;
  80 + },
  81 +}
  82 +module.exports = {
  83 + is_has_rank:g_filters.is_has_rank,
  84 + get_card_price:g_filters.get_card_price,
  85 +}
0 \ No newline at end of file 86 \ No newline at end of file
packageA/pages/service_share/service_share.js 0 → 100644
  1 +// packageA//pages/goods_share/goods_share.js
  2 +var app=getApp(),oo = app.globalData.setting,os=oo,ut = require("../../../utils/util.js");
  3 +Page({
  4 + /**
  5 + * 页面的初始数据
  6 + */
  7 + data: {
  8 + // 控制价格
  9 + active1: false,
  10 + // 控制佣金
  11 + active2: false,
  12 + url:oo.imghost,
  13 + orderField:'sales_sum',
  14 + orderType:'desc',
  15 + list:[],
  16 + is_load:0, //是否正在加载
  17 + is_no_data:0, //没有数据
  18 + is_no_more:0, //没有更多数据
  19 + key_str:'',
  20 + pattern:0, //分成的方式
  21 + currentPage:1, //当前的页码
  22 +
  23 + canvasHidden: 1, //-- 隐藏画布 --
  24 + dis_switch:0, //-- 分销开关 --
  25 + pattern:0, //-- 分成的方式 --
  26 + share_hidden:1, //-- 分享的按钮隐藏 --
  27 + share_good:null //--- 要分享的商品 ---
  28 + },
  29 + /**
  30 + * 生命周期函数--监听页面加载
  31 + */
  32 + onLoad: function (options) {
  33 + var th=this;
  34 + //接受有没有导购的参数
  35 + var first_leader=options.first_leader;
  36 + var StaffId=options.StaffId;
  37 + var StorageId=options.StorageId;
  38 + if(first_leader){
  39 + //-- user_id代过来免登录 --
  40 + getApp().globalData.user_id=first_leader;
  41 + getApp().getUserFir();
  42 +
  43 + //设置分享会员和导购id和归属门店ID
  44 + this.setData({first_leader:first_leader,StaffId:StaffId,StorageId:StorageId});
  45 + }
  46 + this.requestGoodsList();
  47 +
  48 + //-- 自定义海报 --
  49 + getApp().request.promiseGet("/api/weshop/goods/poster/page",{
  50 + data:{store_id:os.stoid, type:1, is_use:1 }
  51 + }).then(res=>{
  52 + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData[0] ){
  53 +
  54 + var poster_data=res.data.data.pageData[0];
  55 + var json_str=poster_data.jsonStr;
  56 +
  57 + if(json_str){
  58 + var json_data=JSON.parse(json_str);
  59 + if(json_data.bg_img){
  60 +
  61 + //-- 把图片那到本地 --
  62 + wx.getImageInfo({
  63 + src:json_data.bg_img,
  64 + success: function(res) {
  65 + var path= res.path;
  66 + th.setData({share_b_img:path})
  67 + },
  68 + fail: function(res) {}
  69 + });
  70 + }
  71 +
  72 + th.setData({poster:json_data})
  73 +
  74 + }
  75 + }
  76 + })
  77 +
  78 + //获取分销的配置
  79 + getApp().request.promiseGet("/api/weshop/storeDistribut/get/"+oo.stoid,{}).then(res=>{
  80 + if(res.data.code==0){
  81 + th.setData({dis_switch:res.data.data.switch,pattern:res.data.data.pattern});
  82 + }
  83 + })
  84 + //获取用户设备信息,屏幕宽度
  85 + wx.getSystemInfo({
  86 + success: res => {
  87 + th.setData({
  88 + screenWidth: res.screenWidth
  89 + })
  90 + }
  91 + });
  92 +
  93 + },
  94 +
  95 + /*** 生命周期函数--监听页面显示***/
  96 + onShow: function () {
  97 + var th=this;
  98 + getApp().getConfig2(function(rs){
  99 + //计算等级价相关
  100 + var swithc_list=rs.switch_list;
  101 + var sw_arr=JSON.parse(swithc_list);
  102 + //---如果后台又开等级卡的开关---
  103 + if(sw_arr.rank_switch && sw_arr.rank_switch=="2"){
  104 + th.setData({rank_switch:true});
  105 + var user=getApp().globalData.userInfo;
  106 +
  107 + //---回调卡的列表---
  108 + th.getPlusCardType(function(ob){
  109 + th.setData({card_list:ob.card_list});
  110 +
  111 + var ti=setInterval(function(){
  112 + if(!user) return false;
  113 + clearInterval(ti);
  114 +
  115 + if(user.card_field && user['card_expiredate']){
  116 + var str = user['card_expiredate'].replace(/-/g, '/');
  117 + var end = new Date(str);
  118 + end = Date.parse(end) / 1000;
  119 + var now = ut.gettimestamp();
  120 + //--- 判断是等级会员,且在有效期范围内 ---
  121 + if(user.card_field && now<end){
  122 + var card_name=ob.name_map.get(user.card_field);
  123 + // if(card_name.length>4) card_name=card_name.substring(0,4);
  124 + th.setData({card_field:user.card_field,card_name:card_name,card_list:ob.card_list});
  125 + }
  126 + }
  127 + },1000)
  128 + })
  129 +
  130 + }
  131 + });
  132 + },
  133 +
  134 + /**
  135 + * 生命周期函数--监听页面隐藏
  136 + */
  137 + onHide: function () {},
  138 + /**e
  139 + * 用户点击右上角分享
  140 + */
  141 + onShareAppMessage: function () {
  142 + var th = this;
  143 + var item=this.data.share_good;
  144 + var price = item.shop_price;
  145 + var title= item.goods_name;
  146 + var img=this.data.url+item.original_img;
  147 +
  148 + var url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + item.goods_id;
  149 + if(getApp().globalData.user_id){
  150 + url+="&first_leader="+getApp().globalData.user_id;
  151 + }
  152 + var ob={
  153 + title: price + "元 " +title,
  154 + path:url,
  155 + imageUrl: img,
  156 + };
  157 + th.setData({share_hidden:1});
  158 + th.insert_goods_share();
  159 + return ob;
  160 +
  161 + },
  162 +
  163 + // 点击价格排序
  164 + sort1() {
  165 + if(this.data.active2) {
  166 + this.setData({
  167 + active2: !this.data.active2
  168 + });
  169 + };
  170 + if(this.data.orderField!="shop_price"){
  171 + this.setData({
  172 + active1: 1,orderField:'shop_price',orderType:'asc',is_no_data:0,is_no_more:0,list:[],
  173 + });
  174 + }else{
  175 +
  176 + var ty=this.data.orderType=='asc'?'desc':'asc';
  177 + this.setData({
  178 + orderType:ty,is_no_data:0,is_no_more:0,list:[],
  179 + });
  180 + }
  181 + this.data.is_load=0;
  182 + this.data.currentPage=1;
  183 + this.requestGoodsList();
  184 +
  185 + },
  186 + // 点击佣金排序
  187 + sort2() {
  188 + if(this.data.active1) {
  189 + this.setData({
  190 + active1: !this.data.active1
  191 + });
  192 + };
  193 + if(this.data.orderField!="commission"){
  194 +
  195 + if(this.data.pattern==0){
  196 + this.setData({
  197 + active2: 1,orderField:'commission',orderType:'asc',is_no_data:0,is_no_more:0,list:[],
  198 + });
  199 + }else{
  200 + this.setData({
  201 + active2: 1,orderField:'(fir_rate+sec_rate+thi_rate)',orderType:'asc',is_no_data:0,is_no_more:0,list:[],
  202 + });
  203 + }
  204 +
  205 +
  206 + }else{
  207 + this.setData({
  208 + orderType: (this.data.orderType=='asc'?'desc':'asc'),is_no_data:0,is_no_more:0,list:[],
  209 + });
  210 + }
  211 + this.data.is_load=0;
  212 + this.data.currentPage=1;
  213 + this.requestGoodsList();
  214 + },
  215 +
  216 + //-- ----销量----
  217 + sale_sort(){
  218 + if(this.data.orderField!="sales_sum"){
  219 + this.setData({
  220 + active1: 0,active2:0,orderType:'desc',is_no_data:0,is_no_more:0,orderField:'sales_sum',list:[],
  221 + });
  222 + this.data.is_load=0;
  223 + this.data.currentPage=1;
  224 + this.requestGoodsList();
  225 + }
  226 + },
  227 +
  228 + //-- ---最新---
  229 + new_sort:function(){
  230 + if(this.data.orderField!="is_new"){
  231 + this.setData({
  232 + active1: 0,active2:0,orderType:'desc',is_no_data:0,is_no_more:0,orderField:'is_new',list:[],
  233 + });
  234 + this.data.is_load=0;
  235 + this.data.currentPage=1;
  236 + this.requestGoodsList();
  237 + }
  238 + },
  239 +
  240 + requestGoodsList:function(){
  241 + var th=this;
  242 + if(th.data.is_load) return false; //-- 正在加载
  243 + if(th.data.is_no_data) return false; //-- 没有数据
  244 + if(th.data.is_no_more) return false; //-- 没有更多
  245 + th.data.is_load=1;
  246 +
  247 + var url="/api/weshop/goods/page";
  248 + var req_data={
  249 + page:this.data.currentPage,
  250 + is_mainshow:1,
  251 + isonsale:1,
  252 + store_id:oo.stoid,
  253 + orderField:this.data.orderField,
  254 + orderType:this.data.orderType,
  255 + }
  256 + if(this.data.key_str && this.data.key_str.trim()){
  257 + var str=this.data.key_str.trim();
  258 + req_data.key_str=str;
  259 + }
  260 + //-- ---调用接口----
  261 + app.request.promiseGet(url,{data:req_data,isShowLoading:1}).then(res=>{
  262 + th.data.is_load=0;
  263 + if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){
  264 + th.data.currentPage++;
  265 + var data=res.data.data.pageData;
  266 + if(res.data.data.page*10>res.data.data.total){th.setData({is_no_more:1});}
  267 + var list=th.data.list;
  268 + list=list.concat(data);
  269 + th.setData({list:list});
  270 + }else{
  271 + if(th.data.currentPage==1){
  272 + th.setData({is_no_data:1});
  273 + }
  274 + }
  275 + })
  276 + },
  277 +
  278 +
  279 + //--- 获取卡类列表 ---
  280 + getPlusCardType: function (func) {
  281 + var storid = oo.stoid;
  282 + var th = this;
  283 + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => {
  284 +
  285 + if(res.data.code!=0 || !res.data.data){
  286 + var ob={"card_list":[],"name_map":''};
  287 + func(ob);
  288 + return false;
  289 + }
  290 +
  291 + var plusCard = res.data.data;
  292 + var arr = [1219, 2089, 3031];
  293 + var new_arr = new Array();
  294 + var card_name_map=new Map();
  295 + var user = getApp().globalData.userInfo;
  296 + for (var i = 0; i < plusCard.length; i++) {
  297 + if ((!user || user.card_field==null || user.card_field=="") && (plusCard[i].IsStopBuy==true)) {
  298 + continue;
  299 + }
  300 + var name="card"+plusCard[i].CorrPrice.toLowerCase();
  301 + card_name_map.set(name,plusCard[i].CardName);
  302 + new_arr.push(plusCard[i]);
  303 + }
  304 +
  305 + var ob={"card_list":new_arr,"name_map":card_name_map};
  306 + func(ob);
  307 + })
  308 + },
  309 +
  310 +
  311 + //---图片失败,默认图片---
  312 + bind_bnerr2: function (e) {
  313 + var _errImg = e.target.dataset.errorimg;
  314 + var _errObj = {};
  315 + _errObj[_errImg] ="/miniapp/images/default_g_img.gif";
  316 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  317 + },
  318 + //-- ---更多加载----
  319 + refresh:function(){
  320 + this.requestGoodsList();
  321 + },
  322 +
  323 + //--定义的保存图片方法,分享团---
  324 + saveImageToPhotosAlbum: function() {
  325 + //--先判断会员状态--
  326 + var user_info = getApp().globalData.userInfo;
  327 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  328 + //getApp().my_warnning("请先登录",0,this);
  329 + wx.navigateTo({ url: '/pages/togoin/togoin', })
  330 + return false;
  331 + }
  332 + //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团
  333 + var type = 0;
  334 + wx.showLoading({
  335 + title: '生成中...',
  336 + })
  337 + var that = this, th = that;
  338 + //设置画板显示,才能开始绘图
  339 + that.setData({
  340 + canvasHidden: false,share_hidden:1
  341 + })
  342 +
  343 + //点击分享
  344 + this.insert_goods_share();
  345 +
  346 + var app = getApp();
  347 + var unit = that.data.screenWidth / 750 * 1.35; //基础单位,
  348 + var scene = th.data.share_good.goods_id+"";
  349 + var user_id=getApp().globalData.user_id?getApp().globalData.user_id:0;
  350 + if(user_id>0){
  351 + scene+="_"+user_id;
  352 + }
  353 +
  354 + ///二微码
  355 + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" +
  356 + os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo";
  357 +
  358 + //读取文件成功则OK--
  359 + wx.getImageInfo({
  360 + src: path3,
  361 + success: function(res) {
  362 + //回调写法
  363 + th.get_head_temp(th.get_goods_temp, function() {
  364 + var vpath = res.path;
  365 + var context = wx.createCanvasContext('share');
  366 + //先画背景
  367 + var pg_path = "../../../images/share/share_bg.png";
  368 +
  369 + //-- 如果有自定义海报的时候,判断背景的图片 --
  370 + if(th.data.share_b_img){
  371 + pg_path=th.data.share_b_img;
  372 + }
  373 + context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit);
  374 +
  375 + //-- 是自定义海报的情况下 --
  376 + if(th.data.poster && parseInt(th.data.poster.style)==2){
  377 + //在线上分享人的情况下
  378 + if(parseInt(th.data.poster.show_headpic)){
  379 + //获取坐标
  380 + var x=parseFloat(th.data.poster.head_x)*2;
  381 + var y=parseFloat(th.data.poster.head_y)*2;
  382 + var x1=(x+90) *unit;
  383 + var y1=(y+50) *unit;
  384 + //--昵称---
  385 + context.setFontSize(24 * unit)
  386 + context.setFillStyle("black")
  387 + context.fillText(app.globalData.userInfo.nickname, x1, y1);
  388 + var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit;
  389 + //强烈推荐 改许程
  390 + var tj_path = "../../../images/share/q_tj.png";
  391 + context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit);
  392 + context.setFontSize(16 * unit)
  393 + context.setLineJoin('round'); //交点设置成圆角
  394 + context.setFillStyle("white")
  395 + context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit);
  396 + }
  397 + }else{
  398 + //--昵称---
  399 + context.setFontSize(24 * unit)
  400 + context.setFillStyle("black")
  401 + context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit);
  402 + var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit;
  403 + //强烈推荐 改许程
  404 + var tj_path = "../../../images/share/q_tj.png";
  405 + context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit);
  406 + context.setFontSize(16 * unit)
  407 + context.setLineJoin('round'); //交点设置成圆角
  408 + context.setFillStyle("white")
  409 + context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 76 * unit);
  410 + }
  411 +
  412 +
  413 + //---产品名称---
  414 + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
  415 + context.setFillStyle("black");
  416 + context.setFontSize(21.3 * unit)
  417 + th.draw_Text(context, th.data.share_good.goods_name,
  418 + 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit);
  419 + //------产品的价格-------
  420 + context.setFontSize(23 * unit)
  421 + context.setFillStyle("red")
  422 + context.fillText("¥", 416 * unit, 185 * unit);
  423 + context.setFontSize(31 * unit)
  424 + var pri0 = th.data.share_good.shop_price;
  425 + if (th.data.prom_act)
  426 + pri0 = th.data.prom_act.price;
  427 +
  428 + pri0 = parseFloat(pri0).toFixed(2);
  429 + context.fillText(pri0, 438 * unit, 185 * unit);
  430 + //---市场价划掉---
  431 + context.setFillStyle("gray")
  432 + context.setFontSize(22 * unit)
  433 + context.fillText("¥" + th.data.share_good.market_price, 426 * unit, 213 * unit);
  434 + context.setStrokeStyle('gray')
  435 + context.setLineWidth(1 * unit)
  436 + context.moveTo(426 * unit, 206 * unit)
  437 + context.lineTo(510 * unit, 206 * unit)
  438 + context.stroke();
  439 + //---中间大图---
  440 + context.drawImage(th.data.share_goods_img, 68 * unit, 242 * unit, 410 * unit, 410 * unit);
  441 + //-------大图后面就不一样了-----------
  442 + switch (type) {
  443 + case 0: //普通商品的展示
  444 + //中间的几个字
  445 + if(th.data.poster && parseInt(th.data.poster.style)==2 ){
  446 + if(parseInt(th.data.poster.show_quality)){
  447 + var g_path = "../../../images/share/s_gou.png";
  448 + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
  449 + context.setFillStyle("red")
  450 + context.setFontSize(18 * unit)
  451 + context.fillText("正品保证", 84 * unit, 690 * unit);
  452 +
  453 + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
  454 + context.setFillStyle("red")
  455 + context.setFontSize(18 * unit)
  456 + context.fillText("纯实体店", 246 * unit, 690 * unit);
  457 +
  458 + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
  459 + context.setFillStyle("red")
  460 + context.setFontSize(18 * unit)
  461 + context.fillText("官方验证", 420 * unit, 690 * unit);
  462 + }
  463 +
  464 + }else{
  465 + var g_path = "../../../images/share/s_gou.png";
  466 + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
  467 + context.setFillStyle("red")
  468 + context.setFontSize(18 * unit)
  469 + context.fillText("正品保证", 84 * unit, 690 * unit);
  470 +
  471 + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
  472 + context.setFillStyle("red")
  473 + context.setFontSize(18 * unit)
  474 + context.fillText("纯实体店", 246 * unit, 690 * unit);
  475 +
  476 + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
  477 + context.setFillStyle("red")
  478 + context.setFontSize(18 * unit)
  479 + context.fillText("官方验证", 420 * unit, 690 * unit);
  480 + }
  481 +
  482 + //---画线---
  483 + context.setLineWidth(1 * unit)
  484 + context.moveTo(32 * unit, 710 * unit)
  485 + context.lineTo(520 * unit, 710 * unit)
  486 + context.stroke();
  487 + //---文字---
  488 + context.setFillStyle("black")
  489 + context.setFontSize(22 * unit)
  490 + // 原来start --->
  491 + context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 776 * unit);
  492 + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 826 * unit);
  493 +
  494 + //---二维吗图---
  495 + //-- 自定义海报 --
  496 + if(th.data.poster){
  497 + var erm_x= parseFloat(th.data.poster.ewm_x)*2;
  498 + var erm_y= parseFloat(th.data.poster.ewm_y)*2;
  499 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
  500 + }else{
  501 + //---二维吗图---
  502 + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
  503 + }
  504 +
  505 + break;
  506 + case 1: //秒杀商品的展示
  507 + //---画线---
  508 + context.setLineWidth(1 * unit)
  509 + context.moveTo(32 * unit, 670 * unit)
  510 + context.lineTo(520 * unit, 670 * unit)
  511 + context.stroke();
  512 +
  513 + //画秒杀的图片
  514 + var miaos_path = '../../../images/share/miao_share.png';
  515 + context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit);
  516 +
  517 + //---文字---
  518 + context.setFontSize(22 * unit)
  519 + context.setFillStyle("black")
  520 + context.fillText("特惠好物,限时秒杀", 40 * unit, 806 * unit);
  521 + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit);
  522 + //---二维吗图---
  523 + //-- 自定义海报 --
  524 + if(th.data.poster){
  525 + var erm_x= parseFloat(th.data.poster.ewm_x)*2;
  526 + var erm_y= parseFloat(th.data.poster.ewm_y)*2;
  527 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
  528 + }else{
  529 + //---二维吗图---
  530 + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
  531 + }
  532 +
  533 +
  534 + break;
  535 +
  536 + case 2: //会员团和商家团的展示
  537 + //---画线---
  538 + context.setLineWidth(1 * unit)
  539 + context.moveTo(32 * unit, 670 * unit)
  540 + context.lineTo(520 * unit, 670 * unit)
  541 + context.stroke();
  542 + //---文字---
  543 + context.setFontSize(22 * unit)
  544 + context.font = 'normal bold';
  545 + context.setFillStyle("black")
  546 + context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit);
  547 +
  548 + //绘制成团图片
  549 + var ct_img = "../../../images/share/ct_num.png";
  550 + context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit);
  551 + var ct_num = th.data.prom_act.ct_num;
  552 + context.setFontSize(14 * unit)
  553 + context.font = 'normal';
  554 + context.setFillStyle("red")
  555 + if (ct_num < 10) {
  556 + context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit);
  557 + } else {
  558 + context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit);
  559 + }
  560 + context.setFontSize(22 * unit)
  561 + context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit);
  562 + context.setFillStyle("gray")
  563 + context.fillText("快来和我一起拼团吧!", 40 * unit, 826 * unit);
  564 + context.setFillStyle("black")
  565 + context.font = 'normal bold 18px sans-serif';
  566 + context.setFontSize(21.3 * unit)
  567 + context.fillText("长按识别二维码,立即参团", 40 * unit, 856 * unit);
  568 + //---二维吗图---
  569 + //-- 自定义海报 --
  570 + if(th.data.poster){
  571 + var erm_x= parseFloat(th.data.poster.ewm_x)*2;
  572 + var erm_y= parseFloat(th.data.poster.ewm_y)*2;
  573 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
  574 + }else{
  575 + //---二维吗图---
  576 + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
  577 + }
  578 + break
  579 + case 3: //阶梯团的展示
  580 + //---画线---
  581 + context.setLineWidth(1 * unit)
  582 + context.moveTo(32 * unit, 670 * unit)
  583 + context.lineTo(520 * unit, 670 * unit)
  584 + context.stroke();
  585 + //---文字---
  586 + context.setFontSize(22 * unit)
  587 + context.font = 'normal bold';
  588 + context.setFillStyle("black")
  589 + context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit);
  590 + //---绘制中间阶梯的价格---
  591 + var list = th.data.prom_act.ct_rylist;
  592 + for (var i = 0; i < list.length; i++) {
  593 + var item = list[i];
  594 + var wi = i * 90 * unit;
  595 + context.font = 'normal';
  596 + context.setFontSize(16 * unit)
  597 + context.setFillStyle("red")
  598 + context.fillText("¥", 40 * unit + wi, 756 * unit);
  599 + context.setFontSize(22 * unit)
  600 + var pri = parseFloat(item.price).toFixed(2);
  601 + context.fillText(pri, 56 * unit + wi, 756 * unit);
  602 + context.setFillStyle("gray")
  603 + context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit);
  604 + }
  605 + //----------------下面部分----------------
  606 + context.setFillStyle("gray")
  607 + context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit);
  608 + context.setFillStyle("black")
  609 + context.font = 'normal bold 18px sans-serif';
  610 + context.setFontSize(22 * unit)
  611 + context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit);
  612 +
  613 + //-- 自定义海报 --
  614 + if(th.data.poster){
  615 + var erm_x= parseFloat(th.data.poster.ewm_x)*2;
  616 + var erm_y= parseFloat(th.data.poster.ewm_y)*2;
  617 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
  618 + }else{
  619 + //---二维吗图---
  620 + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
  621 + }
  622 + break
  623 + }
  624 +
  625 +
  626 + //--- 如果是自定义海报的时候 ---
  627 + if(th.data.poster && parseInt(th.data.poster.style)==2){
  628 + //如果显示会员信息的话
  629 + if(parseInt(th.data.poster.show_headpic)){
  630 + //获取坐标
  631 + var x= parseFloat(th.data.poster.head_x)*2;
  632 + var y=parseFloat(th.data.poster.head_y)*2;
  633 + //---绘制圆形要放在最后----
  634 + context.save();
  635 + context.beginPath();
  636 + var h_x = x* unit;
  637 + var h_y = y * unit;
  638 + var h_r = 40 * unit;
  639 + var cx = h_x + h_r;
  640 + var cy = h_y + h_r;
  641 + context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
  642 + context.closePath();
  643 + context.fill();
  644 + context.clip();
  645 + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
  646 + context.restore();
  647 + }
  648 +
  649 + }else{
  650 + //---绘制圆形要放在最后----
  651 + context.save();
  652 + context.beginPath();
  653 + var h_x = 60 * unit;
  654 + var h_y = 24 * unit;
  655 + var h_r = 40 * unit;
  656 + var cx = h_x + h_r;
  657 + var cy = h_y + h_r;
  658 + context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
  659 + context.closePath();
  660 + context.fill();
  661 + context.clip();
  662 + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
  663 + context.restore();
  664 + }
  665 +
  666 +
  667 + //把画板内容绘制成图片,并回调 画板图片路径
  668 + context.draw(false, function() {
  669 + setTimeout(function() {
  670 + wx.canvasToTempFilePath({
  671 + x: 0,
  672 + y: 0,
  673 + width: 750,
  674 + height: 1217,
  675 + destWidth: 1.2 * 750 * 750 / that.data.screenWidth,
  676 + destHeight: 1.2 * 1217 * 750 / that.data.screenWidth,
  677 + canvasId: 'share',
  678 + success: function(res) {
  679 + that.setData({
  680 + shareImgPath: res.tempFilePath,
  681 + canvasHidden: true
  682 + })
  683 + if (!res.tempFilePath) {
  684 + wx.showModal({
  685 + title: '提示',
  686 + content: '图片绘制中,请稍后重试',
  687 + showCancel: false
  688 + })
  689 + return false;
  690 + }
  691 + wx.previewImage({
  692 + //将图片预览出来
  693 + urls: [that.data.shareImgPath]
  694 + });
  695 + wx.hideLoading();
  696 + }
  697 + })
  698 + }, 500)
  699 +
  700 + });
  701 + });
  702 + }
  703 + });
  704 +
  705 + },
  706 +
  707 + //点击分享商品
  708 + share_good:function(e){
  709 + //--先判断会员状态--
  710 + var user_info = getApp().globalData.userInfo;
  711 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  712 + //getApp().my_warnning("请先登录",0,this);
  713 + wx.navigateTo({ url: '/pages/togoin/togoin', })
  714 + return false;
  715 + }
  716 +
  717 + var index=e.currentTarget.dataset.index;
  718 + var item=this.data.list[index];
  719 + this.setData({share_hidden:0,share_good:item});
  720 + },
  721 +
  722 + cancel:function(){
  723 + this.setData({share_hidden:1});
  724 + },
  725 +
  726 + //--获取头像的本地缓存,回调写法--
  727 + get_head_temp: function(tt, func) {
  728 + var ee = this;
  729 + if (ee.data.share_head) {
  730 + tt(func);
  731 + return false;
  732 + }
  733 + //---获取分享图片的本地地址,头像和商品图片----
  734 + var path2 = getApp().globalData.userInfo.head_pic;
  735 + if (path2 == "") {
  736 + ee.data.share_head = "../../../images/share/hui_hear_pic.png";
  737 + tt(func);
  738 + } else {
  739 + path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
  740 + path2 = path2.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
  741 + wx.getImageInfo({
  742 + src: path2,
  743 + success: function(res) {
  744 + //res.path是网络图片的本地地址
  745 + ee.data.share_head = res.path;
  746 + tt(func);
  747 + },
  748 + fail: function(res) {
  749 + ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的
  750 + tt(func);
  751 + }
  752 + });
  753 + }
  754 + },
  755 + //--获取商品图片的本地缓存,回调写法--
  756 + get_goods_temp: function(tt) {
  757 + var ee = this;
  758 + //获取商品是分享图信息
  759 + wx.getImageInfo({
  760 + src: ee.data.url+ee.data.share_good.original_img,
  761 + success: function(res) {
  762 + //res.path是网络图片的本地地址
  763 + ee.data.share_goods_img = res.path;
  764 + tt();
  765 + },
  766 + fail: function(res) {
  767 + ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的
  768 + tt();
  769 + }
  770 + });
  771 + },
  772 +
  773 + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
  774 + draw_Text: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) {
  775 + var lineWidth = 0;
  776 + var lastSubStrIndex = 0; //每次开始截取的字符串的索引
  777 + var han = 0;
  778 + for (let i = 0; i < str.length; i++) {
  779 + if (han == 2) return;
  780 + //lineWidth += ctx.measureText(str[i]).width;
  781 + lineWidth += ut.measureText(str[i], 21.3 * unit);
  782 + if (lineWidth > canvasWidth) {
  783 + han++;
  784 +
  785 + if (han == 2)
  786 + ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分
  787 + else
  788 + ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight);
  789 +
  790 + initHeight += 22; //22为字体的高度
  791 + lineWidth = 0;
  792 + lastSubStrIndex = i;
  793 + titleHeight += 20;
  794 + }
  795 + if (i == str.length - 1) { //绘制剩余部分
  796 + ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight);
  797 + }
  798 + }
  799 + },
  800 +
  801 + //-------搜索的相关功能------
  802 + set_search_value:function(e){
  803 + var key_str=e.detail.value;
  804 + if(key_str) key_str=key_str.trim();
  805 + this.setData({key_str:key_str});
  806 +
  807 + },
  808 + search_data:function(){
  809 + this.setData({
  810 + is_no_data:0,is_no_more:0,list:[],
  811 + });
  812 + this.data.is_load=0;
  813 + this.data.currentPage=1;
  814 + this.requestGoodsList();
  815 + },
  816 +
  817 + go_goods:function(e){
  818 + var index=e.currentTarget.dataset.index;
  819 + var item=this.data.list[index];
  820 + var url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + item.goods_id;
  821 + getApp().goto(url);
  822 + },
  823 +
  824 + insert_goods_share:function(){
  825 + var th = this;
  826 + var item=this.data.share_good;
  827 + var url="/api/weshop/sharetypeList/save";
  828 + var req_data={
  829 + shareActId:item.goods_id,
  830 + shareActName:item.goods_name,
  831 + shareType:2,
  832 + shareUserId:th.data.first_leader,
  833 + shareStaffId:th.data.StaffId,
  834 + shareStorageId:th.data.StorageId,
  835 + shareTime:ut.gettimestamp(),
  836 + storeId:os.stoid
  837 + }
  838 + //插入数据
  839 + getApp().request.post(url,{
  840 + data:req_data,
  841 + success:function(){
  842 +
  843 + }
  844 + })
  845 +
  846 + //收入线下数据
  847 + req_data.userId=th.data.first_leader;
  848 + delete req_data.shareUserId;
  849 + //插入数据
  850 + getApp().request.post('/api/weshop/MdShareType/saveShare',{
  851 + data:req_data,
  852 + success:function(){}
  853 + })
  854 +
  855 + }
  856 +
  857 +
  858 +})
0 \ No newline at end of file 859 \ No newline at end of file
packageA/pages/service_share/service_share.json 0 → 100644
  1 +{
  2 + "navigationBarTitleText": "服务卡项分享",
  3 + "usingComponents": {
  4 + "nodata": "/components/nodata/nodata",
  5 + "share_button": "/components/share/share"
  6 + },
  7 + "enablePullDownRefresh": false
  8 +}
0 \ No newline at end of file 9 \ No newline at end of file
packageA/pages/service_share/service_share.wxml 0 → 100644
  1 +<wxs module="g_filter" src="g_filter.wxs"></wxs>
  2 +<wxs module="filters" src="../../../utils/filter.wxs"></wxs>
  3 +<view class="container">
  4 + <!-- 搜索框 -->
  5 + <view class="search-container">
  6 + <view class="input-container"><input bindinput="set_search_value" class="search" type="text" placeholder="请输入您想查找的商品信息"/></view>
  7 + <view bindtap="search_data" class="btn-search">搜索</view>
  8 + </view>
  9 + <!-- 列表 -->
  10 + <view class="list-container">
  11 + <!-- 标题 -->
  12 + <view class="title">
  13 + <view class="title-item f1" bindtap="sale_sort">销量</view>
  14 +
  15 + <block wx:if="{{orderField=='shop_price'}}">
  16 + <view class="title-item f1" bindtap="sort1">价格<text class="iconfont {{orderType=='asc'?'icon-shang':'icon-xia'}}"></text></view>
  17 + </block>
  18 + <block wx:else>
  19 + <view class="title-item f1" bindtap="sort1">价格<text class="iconfont icon-shang"></text></view>
  20 + </block>
  21 +
  22 + <!-- <block wx:if="{{orderField=='commission'}}">
  23 + <view class="title-item" bindtap="sort2">佣金<text class="iconfont {{orderType=='asc'?'icon-shang':'icon-xia'}}"></text></view>
  24 + </block>
  25 + <block wx:else>
  26 + <view class="title-item" bindtap="sort2">佣金<text class="iconfont icon-xia"></text></view>
  27 + </block> -->
  28 +
  29 + <view class="title-item f1" bindtap='new_sort'>最新</view>
  30 + </view>
  31 + <!-- 列表项 -->
  32 + <scroll-view
  33 + class="list"
  34 + scroll-y="true"
  35 + bindscrolltolower="refresh"
  36 + scroll-anchoring
  37 + >
  38 + <block wx:for="{{list}}">
  39 + <view class class="list-item" bindtap="go_goods" data-index="{{index}}">
  40 + <view class="img-container">
  41 + <image src="{{url+item.original_img}}" style="width: 100%; height: 100%;"
  42 + binderror="bind_bnerr2" lazy-load="true"
  43 + data-errorimg="list[{{index}}].original_img"></image>
  44 + </view>
  45 + <view class="details">
  46 + <view class="ellipsis-2 fs28 name">{{item.goods_name}}</view>
  47 + <view class="fs26 pdt10">有效天数:365</view>
  48 + <view class="flex ai-center pdt14 jc_sb">
  49 + <view class="red fs26">¥{{item.shop_price}}</view>
  50 + <view class="gray fs24">已售:<text class="red">{{item.sales_sum}}</text></view>
  51 + <!-- <view class="txt_line">¥{{item.market_price}}</view> -->
  52 + </view>
  53 +
  54 + <view class="t-r">
  55 + <!-- 如果有等级卡的话 -->
  56 + <!-- <block wx:if="{{g_filter.is_has_rank(rank_switch,item)}}"> -->
  57 + <!-- 当会员是等级卡的时候,且卡有钱的时候 -->
  58 + <!-- <block wx:if="{{card_field && item[card_field]>0}}"> -->
  59 + <!-- <text class="plus_show">card_name</text>¥{{item[card_field]}} -->
  60 + <!-- <view class="card_bg ellipsis-1 flex ai-center">
  61 + <image src="{{url}}/miniapp/images/plus/dj_icon.png"></image>
  62 + <text class="card_name">{{card_name}}</text>
  63 + </view>
  64 + <view class="fs28">¥{{filters.toFix(item[card_field],2)}}</view>
  65 +
  66 + </block> -->
  67 + <!-- 当会员不是等级卡的时候,且卡有钱的时候 -->
  68 + <!-- <block wx:if="{{!card_field && g_filter.get_card_price(item,card_list,0)>0}}">
  69 + <view class="card_bg ellipsis-1 flex ai-center">
  70 + <image src="{{url}}/miniapp/images/plus/dj_icon.png"></image>
  71 + <text class="card_name">{{g_filter.get_card_price(item,card_list,1)}}</text>
  72 + </view>
  73 + <view class="fs28">¥{{g_filter.get_card_price(item,card_list,0)}}</view>
  74 +
  75 + </block>
  76 + </block>
  77 + </view> -->
  78 +
  79 + <!-- <view class="flex jc_sb fs24 pdt14">
  80 + <view class="gray">已售:<text class="red">{{item.sales_sum}}</text></view>
  81 + <view class="gray">分成金额:
  82 + <text wx:if="{{!pattern}}" class="red">¥{{item.commission}}</text>
  83 + <text wx:else class="red">¥{{item.fir_rate+item.sec_rate+item.thi_rate}}</text>
  84 + </view>
  85 + </view> -->
  86 + <view catchtap="share_good" data-index="{{index}}" class="t-r fs28 pdt14">
  87 + <view class="btn-share">分享</view>
  88 + </view>
  89 + </view>
  90 + </view>
  91 + </view>
  92 + </block>
  93 + <nodata wx:if="{{list.length==0}}" nodataContainer="nodata">暂无数据</nodata>
  94 + <view wx:if="{{is_no_more}}" class="no-more t-c">- 已全部加载 -</view>
  95 + </scroll-view>
  96 + </view>
  97 +</view>
  98 +
  99 +<!--二维码显示页面-->
  100 +<canvas canvas-id='share' style='width:750rpx;height:1217rpx;' wx:if='{{!canvasHidden}}'></canvas>
  101 +<!-- 分享控件,底部弹出 -->
  102 +<share_button id="share_button" bind:cancel="cancel" bind:share_img="saveImageToPhotosAlbum" wx:if="{{!share_hidden}}"></share_button>
packageA/pages/service_share/service_share.wxss 0 → 100644
  1 +/* packageA//pages/goods_share/goods_share.wxss */
  2 +.red {
  3 + color: #FE6867;
  4 +}
  5 +.gray {
  6 + color: #7b7b7b;
  7 +}
  8 +page {
  9 + background-color: #f2f2f2;
  10 + height: 100%;
  11 +}
  12 +.container {
  13 + background-color: white;
  14 + height: 100%;
  15 +}
  16 +.search-container {
  17 + display: flex;
  18 + padding: 26rpx 20rpx;
  19 + border-bottom: 2rpx solid #f8f8f8;
  20 +}
  21 +.input-container {
  22 + flex: 1;
  23 + border-radius: 6rpx 0 0 6rpx;
  24 + overflow: hidden;
  25 +}
  26 +.search {
  27 + background-color: #f0f0f0;
  28 + padding: 10rpx 20rpx;
  29 + font-size: 28rpx;
  30 +}
  31 +.btn-search {
  32 + background-color: #FE6867;
  33 + color: white;
  34 + padding: 0 30rpx;
  35 + display: flex;
  36 + align-items: center;
  37 + border-radius: 0 6rpx 6rpx 0;
  38 +}
  39 +.title {
  40 + display: flex;
  41 + font-size: 30rpx;
  42 + border-bottom: 2rpx solid #f8f8f8;
  43 +}
  44 +.title .iconfont {
  45 + color: #ccc;
  46 + font-size: 16rpx;
  47 + margin-left: 8rpx;
  48 +}
  49 +.title-item {
  50 + width: 25%;
  51 + box-sizing: border-box;
  52 + text-align: center;
  53 + padding: 20rpx;
  54 +}
  55 +.list-container {
  56 + height: calc(100% - 118rpx);
  57 +}
  58 +.list {
  59 + height: calc(100% - 82rpx);
  60 + background-color: #f2f2f2;
  61 +}
  62 +.list-item {
  63 + display: flex;
  64 + padding: 20rpx;
  65 + border-bottom: 2rpx solid #f8f8f8;
  66 + background-color: white;
  67 +}
  68 +.img-container {
  69 + background-color: #f0f0f0;
  70 + width: 280rpx;
  71 + height: 248rpx;
  72 + display: flex;
  73 + align-items: center;
  74 + justify-content: center;
  75 +}
  76 +.img-container:after {
  77 + /* font-family: iconfont;
  78 + content: '\e8c1';
  79 + color: #bbb;
  80 + font-size: 80rpx; */
  81 +}
  82 +.details {
  83 + flex: 1;
  84 + padding-left: 20rpx;
  85 +}
  86 +.btn-share {
  87 + display: inline-block;
  88 + background-color: #FE6867;
  89 + color: white;
  90 + padding: 8rpx 30rpx;
  91 + border-radius: 6rpx;
  92 +}
  93 +.pdt14 {
  94 + padding-top: 14rpx;
  95 +}
  96 +
  97 +.no-more {
  98 + line-height: 3;
  99 + color: #ccc;
  100 + background-color: #f2f2f2;
  101 +}
  102 +.nodata {
  103 + text-align: center;
  104 + background-color: #f2f2f2;
  105 +}
  106 +
  107 +.name {
  108 + height: 76rpx;
  109 +}
  110 +
  111 +.plus_show{
  112 + background-color: #FE6867;
  113 + color: #fff;
  114 + padding: 3rpx 5rpx;
  115 + border-radius:8rpx ;
  116 + margin-left: 10rpx;
  117 + margin-right: 5rpx;
  118 +}
  119 +
  120 +.card_bg {
  121 + box-sizing: border-box;
  122 + padding: 2rpx 10rpx;
  123 + height: 28rpx;
  124 + border-radius: 26rpx;
  125 + font-size: 18rpx;
  126 + line-height: 28rpx;
  127 + max-width: 210rpx;
  128 + background: #333;
  129 + color: #fff;
  130 + margin-left: 8rpx;
  131 +}
  132 +
  133 +.card_bg image {
  134 + width: 19rpx;
  135 + height: 19rpx;
  136 + margin-right: 8rpx;
  137 +}
  138 +
  139 +.txt_line{
  140 + text-decoration: line-through; position: relative;
  141 + top: 23rpx;color: #adadad;
  142 + font-size: 24rpx; margin-left: 10rpx;
  143 + }