sharp-agezi 5 лет назад
Родитель
Сommit
00b7082eff
3 измененных файлов с 228 добавлено и 223 удалено
  1. 82 79
      customized/pages/boxMade/boxComb/boxComb.js
  2. 141 139
      pages/index/index.js
  3. 5 5
      pages/momo/momo.js

+ 82 - 79
customized/pages/boxMade/boxComb/boxComb.js

@@ -52,24 +52,23 @@ Page({
     //   /*底部 */
     // },
     imgSrcArray: [],
-    buildSrcArrayText:{
-      '1':'正面',
-      '2':'背面',
+    buildSrcArrayText: {
+      '1': '正面',
+      '2': '背面',
     },
-    boxImg:{
+    boxImg: {
       '5': '/customized/images/customized/box_white_big_1_out.png',
       '6': '/customized/images/customized/box_white_big_2_out.png',
     },
     buildSrcArray: [],
-    customGoodsImg:"",
+    customGoodsImg: "",
 
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad: function (options) {
-  },
+  onLoad: function (options) {},
 
   /**
    * 生命周期函数--监听页面初次渲染完成
@@ -79,7 +78,8 @@ Page({
     wx.showLoading({
       title: '图片合成中...'
     })
-    let that = this, result = true;
+    let that = this,
+      result = true;
 
     if (wx.getStorageSync('madeCupImgData5') || wx.getStorageSync('madeCupFontData5')) {
       that.getCombImg(that, 5);
@@ -135,16 +135,17 @@ Page({
   onShareAppMessage: function () {
 
   },
-  getCombImg(that,i) {
-    let imgTouch = null, dataPositionObj=null;
+  getCombImg(that, i) {
+    let imgTouch = null,
+      dataPositionObj = null;
     that.setData({ // imgSrcArray 初始化
-      imgSrcArray:[],
+      imgSrcArray: [],
     })
-    console.log(wx.getStorageSync('madeCupImgData' + i),"wx.getStorageSync('madeCupImgData' + i)")
-    if(wx.getStorageSync('madeCupImgData' + i)){
-      imgTouch = wx.getStorageSync('madeCupImgData'+i);
+    console.log(wx.getStorageSync('madeCupImgData' + i), "wx.getStorageSync('madeCupImgData' + i)")
+    if (wx.getStorageSync('madeCupImgData' + i)) {
+      imgTouch = wx.getStorageSync('madeCupImgData' + i);
       dataPositionObj = util.changeCup(i.toString()).dataPositionObj;
-      console.log(dataPositionObj,"dataPositionObj")
+      console.log(dataPositionObj, "dataPositionObj")
       wx.getSystemInfo({
         success: function (res) {
           let rpx = res.windowWidth / 750;
@@ -161,16 +162,16 @@ Page({
                 let dWidth = dataPositionObj.width / imgTouch.width;
                 // canvas截图区域与图片的高度比例
                 let dHeight = dataPositionObj.height / imgTouch.height;
-                const ctx = wx.createCanvasContext('comb-img'+i);
+                const ctx = wx.createCanvasContext('comb-img' + i);
                 //画布中点坐标转移到图片中心
                 let movex = imgTouch.x + imgTouch.width * rpx / 2;
                 let movey = imgTouch.y + imgTouch.height * rpx / 2;
                 ctx.translate(movex, movey);
                 ctx.rotate(imgTouch.angle * Math.PI / 180);
                 ctx.drawImage(res.tempFilePath, -imgTouch.width * rpx / 2, -imgTouch.height * rpx / 2, imgTouch.width * rpx, imgTouch.height * rpx)
-                ctx.draw(false,function () {
+                ctx.draw(false, function () {
                   wx.canvasToTempFilePath({
-                    canvasId: 'comb-img'+i,
+                    canvasId: 'comb-img' + i,
                     success: function (res) {
                       console.log(res)
                       let imgArray = that.data.imgSrcArray;
@@ -178,7 +179,7 @@ Page({
                       that.setData({
                         imgSrcArray: imgArray
                       })
-                      that.getCombFont(that,i,true);
+                      that.getCombFont(that, i, true);
                     }
                   }, that)
                 })
@@ -189,25 +190,27 @@ Page({
         },
       })
     } else {
-      that.getCombFont(that,i,false);
+      that.getCombFont(that, i, false);
     }
-    
-    
-    
+
+
+
   },
-  getCombFont(that,i,_static) {
-    let fontTouch = null, dataPositionObj = null, simulationFont=null;
+  getCombFont(that, i, _static) {
+    let fontTouch = null,
+      dataPositionObj = null,
+      simulationFont = null;
     if (wx.getStorageSync('madeCupFontData' + i)) {
       fontTouch = wx.getStorageSync('madeCupFontData' + i);
       simulationFont = wx.getStorageSync('simulationFont' + i);
       dataPositionObj = util.changeCup(i.toString()).dataPositionObj;
-      const ctx = wx.createCanvasContext('comb-font'+i);
+      const ctx = wx.createCanvasContext('comb-font' + i);
       // ctx.textBaseline = 'top';
       ctx.setFontSize(fontTouch.fontSize);
       ctx.setFillStyle(fontTouch.isColor);
-      if(fontTouch.bold){
+      if (fontTouch.bold) {
         ctx.fillText(fontTouch.fontContent, -1, simulationFont.height / 5 * 4)
-        ctx.fillText(fontTouch.fontContent, 0, simulationFont.height / 5 * 4 -1)
+        ctx.fillText(fontTouch.fontContent, 0, simulationFont.height / 5 * 4 - 1)
       }
       ctx.fillText(fontTouch.fontContent, 0, simulationFont.height / 5 * 4)
       if (fontTouch.bold) {
@@ -215,57 +218,57 @@ Page({
         ctx.fillText(fontTouch.fontContent, 0, simulationFont.height / 5 * 4 + 1)
       }
       ctx.restore()
-      ctx.draw(false,function () {
+      ctx.draw(false, function () {
         wx.canvasToTempFilePath({
-          canvasId: 'comb-font'+i,
+          canvasId: 'comb-font' + i,
           success: function (res) {
             console.log(res)
-            that.getCombFontImg(that, res.tempFilePath, fontTouch,i)
+            that.getCombFontImg(that, res.tempFilePath, fontTouch, i)
           }
         }, that)
       })
     } else {
       that.getComb(that, that.data.imgSrcArray, i, _static)
     }
-    
+
   },
-  getCombFontImg(that, img, fontTouch,i){ // 生产字体图片后在进行处理一次
+  getCombFontImg(that, img, fontTouch, i) { // 生产字体图片后在进行处理一次
     wx.getSystemInfo({
       success: function (res) {
         let rpx = res.windowWidth / 750;
         that.setData({
           rpx: rpx
         });
-            // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
-            console.log(res)
-              // canvas截图区域与图片的宽度比例
-              const ctx = wx.createCanvasContext('comb-font' + i + '-2');
-              //画布中点坐标转移到图片中心
-              let movex = fontTouch.x + 536 * rpx / 2;
-              let movey = fontTouch.y + 712 * rpx / 2;
-              ctx.translate(movex, movey);
-              ctx.rotate(fontTouch.angle * Math.PI / 180);
-              ctx.drawImage(img, -536 * rpx / 2, -712 * rpx / 2, 536 * rpx, 712 * rpx)
-              ctx.draw(false, function () {
-                wx.canvasToTempFilePath({
-                  canvasId: 'comb-font' + i + '-2',
-                  success: function (res) {
-                    console.log(res)
-                     let imgArray = that.data.imgSrcArray;
-                    imgArray.push(res.tempFilePath)
-                    that.setData({
-                      imgSrcArray: imgArray
-                    })
-                    that.getComb(that, that.data.imgSrcArray,i,true)
-                  }
-                }, that)
+        // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
+        console.log(res)
+        // canvas截图区域与图片的宽度比例
+        const ctx = wx.createCanvasContext('comb-font' + i + '-2');
+        //画布中点坐标转移到图片中心
+        let movex = fontTouch.x + 536 * rpx / 2;
+        let movey = fontTouch.y + 712 * rpx / 2;
+        ctx.translate(movex, movey);
+        ctx.rotate(fontTouch.angle * Math.PI / 180);
+        ctx.drawImage(img, -536 * rpx / 2, -712 * rpx / 2, 536 * rpx, 712 * rpx)
+        ctx.draw(false, function () {
+          wx.canvasToTempFilePath({
+            canvasId: 'comb-font' + i + '-2',
+            success: function (res) {
+              console.log(res)
+              let imgArray = that.data.imgSrcArray;
+              imgArray.push(res.tempFilePath)
+              that.setData({
+                imgSrcArray: imgArray
               })
+              that.getComb(that, that.data.imgSrcArray, i, true)
+            }
+          }, that)
+        })
       },
     })
   },
-  getComb(that, imgSrcArray,i,_static) {
-    console.log(imgSrcArray,"imgSrcArray")
-    if(_static){
+  getComb(that, imgSrcArray, i, _static) {
+    console.log(imgSrcArray, "imgSrcArray")
+    if (_static) {
       let imgTouch = wx.getStorageSync('madeCupImgData' + i);
       let dataPositionObj = util.changeCup(i.toString()).dataPositionObj;
       let canvasBg = that.data.obverseImgObject[i];
@@ -285,12 +288,12 @@ Page({
           })
           console.log('开始执行叠加')
           ctx.drawImage(that.data.boxImg[i], 0, 0, 750 * rpx, 800 * rpx)
-      
+
           ctx.draw(true, function () {
             wx.canvasToTempFilePath({
               canvasId: 'comb-canvas' + i,
               success: function (res) {
-                that.uploadFile(res.tempFilePath,that,function(data){
+                that.uploadFile(res.tempFilePath, that, function (data) {
                   console.log(res, "合成成功");
 
                   let buildSrcArray = that.data.buildSrcArray;
@@ -311,7 +314,7 @@ Page({
                     wx.hideLoading()
                   }
                 })
-                
+
               },
               fail: function (err) {
                 console.log(err, "合成失败")
@@ -329,32 +332,32 @@ Page({
         wx.hideLoading()
       }
     }
-    
+
   },
-  addImgRouter(){ // add car
-  let that = this;
-    console.log(that.data.customGoodsImg,"that.data.customGoodsImg")
-    
+  addImgRouter() { // add car
+    let that = this;
+    console.log(that.data.customGoodsImg, "that.data.customGoodsImg")
+
     wx.request({
       url: host + '/addShopCar',
-      method:'post',
+      method: 'post',
       header: {
         'content-type': 'application/x-www-form-urlencoded'
       },
-      data:{
-        customGoodsImg: that.data.customGoodsImg.substring(0, that.data.customGoodsImg.length-1),
-        customGoodsName:'奶缸-黑色 350ml',
+      data: {
+        customGoodsImg: that.data.customGoodsImg.substring(0, that.data.customGoodsImg.length - 1),
+        customGoodsName: '拉杆箱-银灰色',
         customGoodsNum: 1,
         userId: app.globalData.user_id,
       },
-      success:function(res){
-        console.log(res,"加入购物车")
-        if(res.data ==='success'){
+      success: function (res) {
+        console.log(res, "加入购物车")
+        if (res.data === 'success') {
           wx.showModal({
             title: '提示',
             content: '加入购物车成功,是否去购物车结算商品?',
-           
-            success:function(res){
+
+            success: function (res) {
               if (res.confirm) {
                 console.log('用户点击确定')
                 wx.redirectTo({
@@ -369,7 +372,7 @@ Page({
       }
     })
   },
-  uploadFile(path,that,cb){
+  uploadFile(path, that, cb) {
     let customGoodsImg = that.data.customGoodsImg;
     wx.uploadFile({
       url: host + 'fileUpload',
@@ -378,11 +381,11 @@ Page({
       formData: {
         file: path,
         userId: app.globalData.user_id,
-        imgStatus: 1,// 表示合成
+        imgStatus: 1, // 表示合成
       },
       success: function (res) {
         console.log(res, "rrrr");
-        customGoodsImg += res.data+',';
+        customGoodsImg += res.data + ',';
         that.setData({
           customGoodsImg: customGoodsImg
         })

+ 141 - 139
pages/index/index.js

@@ -2,10 +2,9 @@
 //获取应用实例
 var app = getApp();
 let host = app.globalData.servsers; // 请求的url
-var coupon = [
-  {
-    coupon_monry : '1000',
-    coupon_rule : '9999',
+var coupon = [{
+    coupon_monry: '1000',
+    coupon_rule: '9999',
     coupon_name: '新年专属红包',
     coupon_begin_time: '2018-01-01',
     coupon_end_time: '2018-02-08'
@@ -30,18 +29,17 @@ var coupon = [
 Page({
   data: {
     urlHttp: '',
-    host : '',
-    scrollLeft: 0,//tab标题的滚动条位置
-    search:{
-      placeholder:"输入搜索关键字"
-    },
-    navTab:[
-      {
-      url:'/',
-      icon:'icon-dingzhijiaju',
-      src:'../../images/news/nav_01.png',
-      text:'杯类'
+    host: '',
+    scrollLeft: 0, //tab标题的滚动条位置
+    search: {
+      placeholder: "输入搜索关键字"
     },
+    navTab: [{
+        url: '/',
+        icon: 'icon-dingzhijiaju',
+        src: '../../images/news/nav_01.png',
+        text: '杯类'
+      },
       {
         url: '/',
         icon: 'icon-dingzhijiaju',
@@ -67,12 +65,11 @@ Page({
         text: '包袋'
       }
     ],
-    navArray:[
-      {
-        src:'/images/news/nav_1.png',
-        bg:'#fafcff',
-        type:0,
-        href:'/'
+    navArray: [{
+        src: '/images/news/nav_1.png',
+        bg: '#fafcff',
+        type: 0,
+        href: '/'
       },
       {
         src: '/images/news/nav_2.png',
@@ -93,11 +90,11 @@ Page({
         href: '/pages/patternMenu/patternMenu'
       }
     ],
-    specArray:[],
-    navList:["推荐","中秋","改良生活","优化办公","智能科技"],
+    specArray: [],
+    navList: ["推荐", "中秋", "改良生活", "优化办公", "智能科技"],
     firstActive: "header_nav_active",
-    currentItem : '',
-    flag:true,
+    currentItem: '',
+    flag: true,
     banners: [],
     rexiao: [],
     tuijian: [],
@@ -131,29 +128,33 @@ Page({
     find_yuedu: '',
     find_shoucang: '',
     datatime: new Date().getTime(),
-    
+
     city_name: '',
-    jingpin: {// 发现精品
-      id: 1, src: "../../images/jingxuan_banner.jpg", title: "各星座员工生日礼品如何选", liulan: 117, zan: 34
+    jingpin: { // 发现精品
+      id: 1,
+      src: "../../images/jingxuan_banner.jpg",
+      title: "各星座员工生日礼品如何选",
+      liulan: 117,
+      zan: 34
     },
     page: 1,
     hasMore: true,
-    hidden : '',
-    winHeight: "",//窗口高度
+    hidden: '',
+    winHeight: "", //窗口高度
     coupon: coupon, //优惠劵
-    showCoupon : false,
-    couponSta : 0,//对于用户来说,是否是第一次显示
-    un_id : '',
-    showMsg : true,  //显示切换模式提示
-    showChangeModel : false,  //显示切换模式确认弹窗
-    bannerFlag : 0,  //banner数量
-    recommendArray:[], // /推荐数组
-    goodsNewsArray:[], //按照时间排序来
+    showCoupon: false,
+    couponSta: 0, //对于用户来说,是否是第一次显示
+    un_id: '',
+    showMsg: true, //显示切换模式提示
+    showChangeModel: false, //显示切换模式确认弹窗
+    bannerFlag: 0, //banner数量
+    recommendArray: [], // /推荐数组
+    goodsNewsArray: [], //按照时间排序来
     // channelId:null ,//用户登录后的id
-    page:1, //默认第一页
-    limit:10, //展示的数量
-    requestState:true, //请求状态,默认是有数据的
-    loginStatic:false, //登陆状态,默认为false
+    page: 1, //默认第一页
+    limit: 10, //展示的数量
+    requestState: true, //请求状态,默认是有数据的
+    loginStatic: false, //登陆状态,默认为false
   },
 
   //tab切换
@@ -162,7 +163,7 @@ Page({
     var name = options.currentTarget.dataset.name;
     var des = options.currentTarget.dataset.des;
     var forid = options.currentTarget.dataset.forid;
-    wx:wx.navigateTo({
+    wx: wx.navigateTo({
       url: '/pages/kindSecondList/kindSecondList?classify_name=' + name + '&classify_des=' + des + '&id=' + forid
     })
   },
@@ -172,14 +173,14 @@ Page({
     var that = this;
     var host = getApp().globalData.servsers;
     var current = e.detail.current;
-    if (e.detail.current == 0){
+    if (e.detail.current == 0) {
       var forid = 0;
-    }else{
+    } else {
       var forid = that.data.navList[e.detail.current - 1].id;
       var forname = that.data.navList[e.detail.current - 1].classify_name;
       var classifydes = that.data.navList[e.detail.current - 1].classify_des;
     }
-    
+
     this.setData({
       currentItem: e.detail.current
     })
@@ -232,7 +233,7 @@ Page({
       //设置当前样式
       that.setData({
         'firstActive': "",
-        'currentItem':0,
+        'currentItem': 0,
         flag: true,
       })
     }
@@ -255,11 +256,11 @@ Page({
     var host = getApp().globalData.servsers;
     var un_id = getApp().globalData.un_id;
     that.setData({
-      urlHttp : host
+      urlHttp: host
     })
     //首页banner
     wx.request({
-      url: host+"homebannerapi/homebannerall",
+      url: host + "homebannerapi/homebannerall",
       data: {},
       method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
       header: {
@@ -272,11 +273,11 @@ Page({
         });
         console.log(res.data.rows);
         //判断banner位置是否为空
-        for (var i = 0; i < res.data.rows.length;i++){
+        for (var i = 0; i < res.data.rows.length; i++) {
           var bannerFlag = that.data.bannerFlag;
-          if (bannerFlag > 0){
+          if (bannerFlag > 0) {
             return false;
-          }else{
+          } else {
             if (res.data.rows[i].banner_flag == 0) {
               bannerFlag++;
               that.setData({
@@ -284,7 +285,7 @@ Page({
               })
               return false;
             }
-          } 
+          }
         }
         //console.log(that.data.banners);
         if (res == null || res.data == null) {
@@ -293,13 +294,13 @@ Page({
         }
       }
     });
-    
+
 
     //品牌定制
     wx.request({
       url: host + "brandapi/findforfirst",
       data: {},
-      method: 'GET', 
+      method: 'GET',
       header: {
         'Accept': 'application/json'
       },
@@ -308,7 +309,7 @@ Page({
           that.setData({
             hidden: 'hidden'
           })
-        }else{
+        } else {
           var img = res.data.rows[0].brand_logo;
           that.setData({
             title1: res.data.rows[0].brand_name,
@@ -342,7 +343,7 @@ Page({
           // })
         } else {
           var img = res.data.rows[0].brand_logo;
-          that.setData({   
+          that.setData({
             title3: res.data.rows[2].brand_name,
             intro3: res.data.rows[2].brand_des,
             src3: res.data.rows[2].brand_logo,
@@ -369,11 +370,11 @@ Page({
           winHeight: calc
         });
       }
-    }); 
-    
+    });
+
   },
 
-  onReady:function(e){
+  onReady: function (e) {
     var that = this;
     var host = getApp().globalData.servsers;
 
@@ -419,39 +420,39 @@ Page({
                 })
                 var un_id = res.data.unionId;
 
-                if (parseInt(nowTime) >= parseInt(beginTimestamp) && parseInt(nowTime) <= parseInt(endTimestamp)) {//当前日期在优惠劵领取时间内
+                if (parseInt(nowTime) >= parseInt(beginTimestamp) && parseInt(nowTime) <= parseInt(endTimestamp)) { //当前日期在优惠劵领取时间内
                   console.log("un_id:" + un_id);
-                  if (un_id != undefined && un_id != '' && un_id != null){
-                      wx.request({//优惠活动-对于用户来说,是否应该显示
-                        url: host + "mycouponapi/getAlertFlag",
-                        data: {
-                          user_id: un_id,
-                          batch_no: 1,
-                          alert_num: 1//优惠活动对于每个用户来说,一共显示的次数
-                        },
-                        method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
-                        header: {
-                          'Accept': 'application/json'
-                        },
-                        success: function (res) {
-                          if (res.data == 0) {
-                            that.setData({
-                              showCoupon: true
-                            })
-                          } else {
-                            that.setData({
-                              showCoupon: false
-                            })
-                          }
-
-                          if (res == null || res.data == null) {
-                            console.error('网络请求失败');
-                            return;
-                          }
+                  if (un_id != undefined && un_id != '' && un_id != null) {
+                    wx.request({ //优惠活动-对于用户来说,是否应该显示
+                      url: host + "mycouponapi/getAlertFlag",
+                      data: {
+                        user_id: un_id,
+                        batch_no: 1,
+                        alert_num: 1 //优惠活动对于每个用户来说,一共显示的次数
+                      },
+                      method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
+                      header: {
+                        'Accept': 'application/json'
+                      },
+                      success: function (res) {
+                        if (res.data == 0) {
+                          that.setData({
+                            showCoupon: true
+                          })
+                        } else {
+                          that.setData({
+                            showCoupon: false
+                          })
                         }
-                      });
+
+                        if (res == null || res.data == null) {
+                          console.error('网络请求失败');
+                          return;
+                        }
+                      }
+                    });
                   }
-                  
+
                 }
                 if (res == null || res.data == null) {
                   console.error('网络请求失败');
@@ -463,20 +464,20 @@ Page({
         })
       }
     })
- 
+
   },
 
   footerTap: app.footerTap,
 
-  onShow:function(){
+  onShow: function () {
     var that = this;
-    that.onLoad();  
+    that.onLoad();
     //商品推荐
     that.getGoodsRecommendList(that);
     // 按照时间排序
     that.setData({
-      goodsNewsArray:[],
-      page:1,
+      goodsNewsArray: [],
+      page: 1,
     })
     that.getGoodsNews(that)
     that.getSpecList(that)
@@ -488,27 +489,27 @@ Page({
   },
 
   //跳转到“发现”tab页
-  find:function(e){
+  find: function (e) {
     wx.switchTab({
-      url : "/pages/find/index"
+      url: "/pages/find/index"
     })
   },
-  getSpecList(that){
+  getSpecList(that) {
     wx.request({
-      url: host+'/classifyapi/classifyTwoAll',
-      method:'get',
-      data:{
-        classifyHigher:3072
+      url: host + '/classifyapi/classifyTwoAll',
+      method: 'get',
+      data: {
+        classifyHigher: 3072
       },
-      success:function(res){
+      success: function (res) {
         console.log(res)
         that.setData({
-          specArray:res.data.rows
+          specArray: res.data.rows
         })
       }
     })
   },
-  onReachBottom(){
+  onReachBottom() {
     var that = this;
     if (that.data.requestState) {
       that.setData({
@@ -520,9 +521,9 @@ Page({
   },
   //下拉刷新
   onPullDownRefresh: function (e) {
-    
+
   },
-  onShareAppMessage: function (res) {//页面分享
+  onShareAppMessage: function (res) { //页面分享
     var that = this;
     var host = getApp().globalData.servsers;
     if (res.from === 'button') {
@@ -530,10 +531,10 @@ Page({
       console.log(res.target)
     }
     return {
-      title:'大良造-精良之选,用心造物!',
+      title: '大良造-精良之选,用心造物!',
       path: '/pages/index/index',
       success: function (res) {
-      
+
       },
       fail: function (res) {
         // 转发失败
@@ -541,23 +542,23 @@ Page({
     }
   },
   //关闭优惠劵弹窗
-  closeCoupon:function(e){
+  closeCoupon: function (e) {
     var that = this;
     that.setData({
-      showCoupon : false
+      showCoupon: false
     })
   },
 
   //关闭切换模式提示
-  closeMsg:function(e){
+  closeMsg: function (e) {
     var that = this;
     that.setData({
-      showMsg : false
+      showMsg: false
     })
   },
 
   //打开切换提示
-  openChangeModel:function(e){
+  openChangeModel: function (e) {
     var that = this;
     that.setData({
       showMsg: false,
@@ -566,10 +567,10 @@ Page({
   },
 
   //跳转至一键选礼
-  goChooseGift:function(e){
+  goChooseGift: function (e) {
     var that = this;
     that.setData({
-      showChangeModel : false
+      showChangeModel: false
     })
     wx.navigateTo({
       url: '/pages/patternMenu/patternMenu'
@@ -577,35 +578,35 @@ Page({
   },
 
   //关闭切换模式确认弹窗
-  closeChangeModel:function(e){
+  closeChangeModel: function (e) {
     var that = this;
     that.setData({
       showChangeModel: false
     })
   },
- // 商品推荐
-  getGoodsRecommendList(that){
-    let data ={
+  // 商品推荐
+  getGoodsRecommendList(that) {
+    let data = {
       limit: 6,
       offset: 1,
       channelId: wx.getStorageSync('channelIdObj').channelId ? wx.getStorageSync('channelIdObj').channelId : ""
     }
     wx.request({
       url: host + '/commodityapi/queryCommodityGroom',
-      method:"get",
+      method: "get",
       data: data,
-      success(res){
+      success(res) {
         res.data.rows.forEach(el => {
           el.logo = el.commodity_logo.split(",")
         })
         that.setData({
-          recommendArray:res.data.rows
+          recommendArray: res.data.rows
         })
       }
     })
   },
   // 按时间排序来的
-  getGoodsNews(that){
+  getGoodsNews(that) {
     let data = {
       limit: that.data.limit,
       offset: that.data.page,
@@ -618,25 +619,26 @@ Page({
       success(res) {
         let goods = that.data.goodsNewsArray;
         console.log(goods)
-        if (that.data.page == 1){
+        if (that.data.page == 1) {
           goods = [];
         }
         goods.push(...res.data.rows);
         console.log(goods)
         that.setData({
           goodsNewsArray: goods,
-          requestState: res.data.rows.length === that.data.limit 
+          requestState: res.data.rows.length === that.data.limit
         })
       }
     })
   },
   toGoodsDetail(e) { // 进入商品详情页
-    let that = this, id = e.currentTarget.dataset.id;
+    let that = this,
+      id = e.currentTarget.dataset.id;
     wx.navigateTo({
       url: '/pages/buy/buy?com_id=' + id,
     })
   },
-  navTap(e){
+  navTap(e) {
     // console.log(e);
     let item = e.currentTarget.dataset.item;
     if (item.type == 1 && !wx.getStorageSync('channelIdObj')) { // 表示是优质的杯,并且还没有登录过渠道
@@ -649,16 +651,16 @@ Page({
       })
     }
   },
-  tapMomo(){
-    if (!wx.getStorageSync('channelIdObj')) { // 还没有登录过渠道
-      wx.navigateTo({
-        url: '/pages/login/login?url=/pages/momo/momo',
-      })
-    } else {
-      wx.switchTo({
-        url: '/pages/momo/momo',
-      })
-    }
+  tapMomo() {
+    // if (!wx.getStorageSync('channelIdObj')) { // 还没有登录过渠道
+    //   wx.navigateTo({
+    //     url: '/pages/login/login?url=/pages/momo/momo',
+    //   })
+    // } else {
+    //   wx.switchTo({
+    //     url: '/pages/momo/momo',
+    //   })
+    // }
   }
 
 })
@@ -674,4 +676,4 @@ var pinpai = []
 // 人气推荐
 var tuijian = []
 var that;
-var Util = require('../../utils/util.js'); 
+var Util = require('../../utils/util.js');

+ 5 - 5
pages/momo/momo.js

@@ -20,8 +20,7 @@ Page({
       "selectedColor": "#e81021",
       "borderStyle": "white",
       "backgroundColor": "#fff",
-      "list": [
-        {
+      "list": [{
           "pagePath": "/pages/index/index",
           "iconPath": "../../images/news/home.png",
           "selectedIconPath": "images/news/home_select.png",
@@ -60,7 +59,7 @@ Page({
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {
-    
+
   },
 
   /**
@@ -69,7 +68,7 @@ Page({
   onShow: function () {
     let that = this;
     if (!wx.getStorageSync('channelIdObj')) { // 还没有登录过渠道
-      wx.navigateTo({
+      wx.redirectTo({
         url: '/pages/login/login?url=/pages/momo/momo && type =1',
       })
     }
@@ -144,7 +143,8 @@ Page({
     })
   },
   toGoodsDetail(e) { // 进入商品详情页
-    let that = this, id = e.currentTarget.dataset.id;
+    let that = this,
+      id = e.currentTarget.dataset.id;
     wx.navigateTo({
       url: '/pages/buy/buy?com_id=' + id,
     })