gemercheung 3 lat temu
rodzic
commit
279e5e1936
2 zmienionych plików z 519 dodań i 506 usunięć
  1. 265 266
      app.js
  2. 254 240
      pages/shared/shared.js

+ 265 - 266
app.js

@@ -1,267 +1,266 @@
-const util = require('./utils/util.js');
-const api = require('./config/api');
-
-
-! function () {
-    var PageTmp = Page;
-    Page = function (pageConfig) {
-        // 设置全局默认分享
-        let tempShare = pageConfig.onShareAppMessage
-        pageConfig.onShareAppMessage = function (...args) {
-            let pages = getCurrentPages()
-            let path = pages[pages.length - 1].route;
-            let defconfig = {
-                title: '【好友推荐】一起来云逛吧~',
-                desc: '【好友推荐】一起来云逛吧~',
-                path: path,
-                imageUrl: 'https://houseoss.4dkankan.com/4dHouse/miniprogram/aaa.jpg',
-            };
-
-            let currConfig = tempShare && tempShare.call(this, ...args)
-            let config = defconfig
-            if (currConfig) {
-                config = {
-                    ...defconfig,
-                    ...currConfig,
-                }
-            }
-
-            return config
-        }
-
-        let onShow = pageConfig.onShow
-        pageConfig.onShow = function (...args) {
-            getApp().setLoginProps(true)
-
-            return onShow.call(this, ...args)
-        }
-
-        PageTmp(pageConfig);
-    };
-}();
-
-const voiceCbs = []
-const voiceProps = {
-    force: true,
-    noMute: false,
-    pullUrls: [],
-    pushUrl: false,
-}
-const loginCbs = []
-const loginProps = {
-    isLogin: true
-};
-
-App({
-    onShareAppMessage() {
-        console.log('--------------------')
-    },
-    onLaunch: function () {
-        //获取小程序更新机制兼容
-        if (wx.canIUse('getUpdateManager')) {
-            const updateManager = wx.getUpdateManager()
-            updateManager.onCheckForUpdate(function (res) {
-                // 请求完新版本信息的回调
-                if (res.hasUpdate) {
-                    updateManager.onUpdateReady(function () {
-                        wx.showModal({
-                            title: '更新提示',
-                            content: '新版本已经准备好,是否重启应用?',
-                            success: function (res) {
-                                if (res.confirm) {
-                                    // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
-                                    updateManager.applyUpdate()
-                                }
-                            }
-                        })
-                    })
-                    updateManager.onUpdateFailed(function () {
-                        // 新的版本下载失败
-                        wx.showModal({
-                            title: '已经有新版本了哟~',
-                            content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
-                        })
-                    })
-                }
-            })
-        } else {
-            // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
-            wx.showModal({
-                title: '提示',
-                content: '当前微信版本过低,无法更好体验程序,请升级到最新微信版本后重试。'
-            })
-        }
-        this.onGetSysInfo()
-    },
-    globalData: {
-        city:  wx.getStorageSync('city') ||'全国',
-        voiceProps,
-        loginProps,
-        userInfo: {
-            nickName: 'Hi,游客',
-            userName: '点击去登录',
-            avatarUrl: 'https://platform-wxmall.oss-cn-beijing.aliyuncs.com/upload/20180727/150547696d798c.png'
-        },
-        token: '',
-        userCoupon: 'NO_USE_COUPON', //默认不适用优惠券
-        courseCouponCode: {}, //购买课程的时候优惠券信息
-        isiPhoneX: false,
-        isLogin: false,
-        // 头部的自定义的高度
-        statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'],
-    },
-
-    addVoicePropsListener(cb) {
-        voiceCbs.push(cb)
-    },
-
-    removeVoicePropsListener(cb) {
-        voiceCbs.splice(voiceCbs.indexOf(cb), 1)
-    },
-    setVoiceProps(props) {
-        console.log(props, 'props')
-        Object.keys(props).forEach(k => {
-            voiceProps[k] = props[k]
-        })
-        voiceCbs.forEach(cb => cb(props))
-    },
-
-    addLoginListener(cb) {
-        loginCbs.push(cb)
-    },
-
-    removeLoginListener(cb) {
-        loginCbs.splice(loginCbs.indexOf(cb), 1)
-    },
-
-    setLoginProps(props) {
-        loginProps.isLogin = props
-        loginCbs.forEach(cb => cb())
-    },
-
-    onGetSysInfo() {
-        // 先缓存获取
-        let isiPhoneX = wx.getStorageSync('isiPhoneX') || false
-        // 缓存没有 再获取
-        if (!isiPhoneX) {
-            wx.getSystemInfo({
-                success: res => {
-                    // 手机品牌
-                    let modelmes = res.model;
-                    console.log('mode---------------lmes', modelmes)
-                    // 如果是 X,XS,XR,XS MAX 均可适配
-                    if (modelmes.indexOf('iPhone X') != -1) {
-                        // 存储型号
-                        this.globalData.isiPhoneX = true
-                        wx.setStorageSync('isiPhoneX', true)
-                        // 加入回调
-                        this.sysCallback && this.sysCallback()
-                    }
-                },
-            })
-        } else {
-            this.globalData.isiPhoneX = isiPhoneX
-        }
-    },
-    // 下拉刷新
-    onPullDownRefresh: function () {
-        // 显示顶部刷新图标
-        wx.showNavigationBarLoading();
-        var that = this;
-        // 隐藏导航栏加载框
-        wx.hideNavigationBarLoading();
-        // 停止下拉动作
-        wx.stopPullDownRefresh();
-
-        this.checkNetStatu()
-    },
-    // 更新小程序
-    updateManager: function () {
-        //获取系统信息 客户端基础库
-        wx.getSystemInfo({
-            success: function (res) {
-                //基础库版本比较,版本更新必须是1.9.90以上
-                const v = util.compareVersion(res.SDKVersion, '1.9.90');
-                if (v > 0) {
-                    const manager = wx.getUpdateManager();
-                    manager.onCheckForUpdate(function (res) {
-                        // 请求完新版本信息的回调
-                        //console.log(res.hasUpdate);
-                    });
-                    manager.onUpdateReady(function () {
-                        wx.showModal({
-                            title: '更新提示',
-                            content: '新版本已经准备好,是否重启应用?',
-                            success: function (res) {
-                                if (res.confirm) {
-                                    // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
-                                    manager.applyUpdate();
-                                }
-                            }
-                        })
-                    });
-                    manager.onUpdateFailed(function () {
-                        // 新的版本下载失败
-                    });
-                } else {
-                    // wx.showModal({
-                    //   title: '温馨提示',
-                    //   content: '当前微信版本过低,无法更好体验程序,请升级到最新微信版本后重试。'
-                    // })
-                }
-            },
-        })
-    },
-
-    getCurrentPages: function () {
-        var pages = getCurrentPages(); //获取加载的页面
-        var currentPage = pages[pages.length - 1]; //获取当前页面的对象
-        var url = currentPage.route; //当前页面url
-        var options = currentPage.options; //获取url中所带的参数
-        //拼接url的参数
-        var currentPage = url + '?';
-        for (var key in options) {
-            var value = options[key]
-            currentPage += key + '=' + value + '&';
-        }
-        currentPage = currentPage.substring(0, currentPage.length - 1);
-        return currentPage;
-    },
-
-
-
-    async checkNetStatu() {
-        if (!(await util.checkNetStatu())) {
-            return wx.redirectTo({
-                url: '/pages/offline/offline?url=' + decodeURI(this.getCurrentPages()),
-            })
-        }
-    },
-
-    updateCardCount() {
-        util.request(api.CartList).then((res) => {
-            //显示红字,badge
-            if (!res.data || !res.data.cartTotal) {
-                return
-            }
-            // global.setTabBarBadge({
-            //     index: 2,
-            //     text: res.data.cartTotal.goodsCount ,
-            // });
-            if (res.data.cartTotal.goodsCount) {
-                wx.setTabBarBadge({
-                    index: 1,
-                    text: res.data.cartTotal.goodsCount + '',
-                });
-            } else {
-                wx.removeTabBarBadge({
-                    index: 1,
-                });
-            }
-        })
-    },
-    onLaunch() {
-        console.error('第一次进来')
-        wx.setStorageSync('lastSceneNum', null)
-    }
+const util = require('./utils/util.js');
+const api = require('./config/api');
+
+
+! function () {
+  var PageTmp = Page;
+  Page = function (pageConfig) {
+    // 设置全局默认分享
+    let tempShare = pageConfig.onShareAppMessage
+    pageConfig.onShareAppMessage = function (...args) {
+      let pages = getCurrentPages()
+      let path = pages[pages.length - 1].route;
+      let defconfig = {
+        title: '【好友推荐】一起来云逛吧~',
+        desc: '【好友推荐】一起来云逛吧~',
+        path: path,
+        imageUrl: 'https://houseoss.4dkankan.com/4dHouse/miniprogram/aaa.jpg',
+      };
+
+      let currConfig = tempShare && tempShare.call(this, ...args)
+      let config = defconfig
+      if (currConfig) {
+        config = {
+          ...defconfig,
+          ...currConfig,
+        }
+      }
+
+      return config
+    }
+
+    let onShow = pageConfig.onShow
+    pageConfig.onShow = function (...args) {
+      getApp().setLoginProps(true)
+      return onShow.call(this, ...args)
+    }
+
+    PageTmp(pageConfig);
+  };
+}();
+
+const voiceCbs = []
+const voiceProps = {
+  force: true,
+  noMute: false,
+  pullUrls: [],
+  pushUrl: false,
+}
+const loginCbs = []
+const loginProps = {
+  isLogin: true
+};
+
+App({
+  onShareAppMessage() {
+    console.log('--------------------')
+  },
+  onLaunch: function () {
+    //获取小程序更新机制兼容
+    if (wx.canIUse('getUpdateManager')) {
+      const updateManager = wx.getUpdateManager()
+      updateManager.onCheckForUpdate(function (res) {
+        // 请求完新版本信息的回调
+        if (res.hasUpdate) {
+          updateManager.onUpdateReady(function () {
+            wx.showModal({
+              title: '更新提示',
+              content: '新版本已经准备好,是否重启应用?',
+              success: function (res) {
+                if (res.confirm) {
+                  // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+                  updateManager.applyUpdate()
+                }
+              }
+            })
+          })
+          updateManager.onUpdateFailed(function () {
+            // 新的版本下载失败
+            wx.showModal({
+              title: '已经有新版本了哟~',
+              content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
+            })
+          })
+        }
+      })
+    } else {
+      // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
+      wx.showModal({
+        title: '提示',
+        content: '当前微信版本过低,无法更好体验程序,请升级到最新微信版本后重试。'
+      })
+    }
+    this.onGetSysInfo()
+  },
+  globalData: {
+    city: wx.getStorageSync('city') || '全国',
+    voiceProps,
+    loginProps,
+    userInfo: {
+      nickName: 'Hi,游客',
+      userName: '点击去登录',
+      avatarUrl: 'https://platform-wxmall.oss-cn-beijing.aliyuncs.com/upload/20180727/150547696d798c.png'
+    },
+    token: '',
+    userCoupon: 'NO_USE_COUPON', //默认不适用优惠券
+    courseCouponCode: {}, //购买课程的时候优惠券信息
+    isiPhoneX: false,
+    isLogin: false,
+    // 头部的自定义的高度
+    statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'],
+  },
+
+  addVoicePropsListener(cb) {
+    voiceCbs.push(cb)
+  },
+
+  removeVoicePropsListener(cb) {
+    voiceCbs.splice(voiceCbs.indexOf(cb), 1)
+  },
+  setVoiceProps(props) {
+    console.log(props, 'props')
+    Object.keys(props).forEach(k => {
+      voiceProps[k] = props[k]
+    })
+    voiceCbs.forEach(cb => cb(props))
+  },
+
+  addLoginListener(cb) {
+    loginCbs.push(cb)
+  },
+
+  removeLoginListener(cb) {
+    loginCbs.splice(loginCbs.indexOf(cb), 1)
+  },
+
+  setLoginProps(props) {
+    loginProps.isLogin = props
+    loginCbs.forEach(cb => cb())
+  },
+
+  onGetSysInfo() {
+    // 先缓存获取
+    let isiPhoneX = wx.getStorageSync('isiPhoneX') || false
+    // 缓存没有 再获取
+    if (!isiPhoneX) {
+      wx.getSystemInfo({
+        success: res => {
+          // 手机品牌
+          let modelmes = res.model;
+          console.log('mode---------------lmes', modelmes)
+          // 如果是 X,XS,XR,XS MAX 均可适配
+          if (modelmes.indexOf('iPhone X') != -1) {
+            // 存储型号
+            this.globalData.isiPhoneX = true
+            wx.setStorageSync('isiPhoneX', true)
+            // 加入回调
+            this.sysCallback && this.sysCallback()
+          }
+        },
+      })
+    } else {
+      this.globalData.isiPhoneX = isiPhoneX
+    }
+  },
+  // 下拉刷新
+  onPullDownRefresh: function () {
+    // 显示顶部刷新图标
+    wx.showNavigationBarLoading();
+    var that = this;
+    // 隐藏导航栏加载框
+    wx.hideNavigationBarLoading();
+    // 停止下拉动作
+    wx.stopPullDownRefresh();
+
+    this.checkNetStatu()
+  },
+  // 更新小程序
+  updateManager: function () {
+    //获取系统信息 客户端基础库
+    wx.getSystemInfo({
+      success: function (res) {
+        //基础库版本比较,版本更新必须是1.9.90以上
+        const v = util.compareVersion(res.SDKVersion, '1.9.90');
+        if (v > 0) {
+          const manager = wx.getUpdateManager();
+          manager.onCheckForUpdate(function (res) {
+            // 请求完新版本信息的回调
+            //console.log(res.hasUpdate);
+          });
+          manager.onUpdateReady(function () {
+            wx.showModal({
+              title: '更新提示',
+              content: '新版本已经准备好,是否重启应用?',
+              success: function (res) {
+                if (res.confirm) {
+                  // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+                  manager.applyUpdate();
+                }
+              }
+            })
+          });
+          manager.onUpdateFailed(function () {
+            // 新的版本下载失败
+          });
+        } else {
+          // wx.showModal({
+          //   title: '温馨提示',
+          //   content: '当前微信版本过低,无法更好体验程序,请升级到最新微信版本后重试。'
+          // })
+        }
+      },
+    })
+  },
+
+  getCurrentPages: function () {
+    var pages = getCurrentPages(); //获取加载的页面
+    var currentPage = pages[pages.length - 1]; //获取当前页面的对象
+    var url = currentPage.route; //当前页面url
+    var options = currentPage.options; //获取url中所带的参数
+    //拼接url的参数
+    var currentPage = url + '?';
+    for (var key in options) {
+      var value = options[key]
+      currentPage += key + '=' + value + '&';
+    }
+    currentPage = currentPage.substring(0, currentPage.length - 1);
+    return currentPage;
+  },
+
+
+
+  async checkNetStatu() {
+    if (!(await util.checkNetStatu())) {
+      return wx.redirectTo({
+        url: '/pages/offline/offline?url=' + decodeURI(this.getCurrentPages()),
+      })
+    }
+  },
+
+  updateCardCount() {
+    util.request(api.CartList).then((res) => {
+      //显示红字,badge
+      if (!res.data || !res.data.cartTotal) {
+        return
+      }
+      // global.setTabBarBadge({
+      //     index: 2,
+      //     text: res.data.cartTotal.goodsCount ,
+      // });
+      if (res.data.cartTotal.goodsCount) {
+        wx.setTabBarBadge({
+          index: 1,
+          text: res.data.cartTotal.goodsCount + '',
+        });
+      } else {
+        wx.removeTabBarBadge({
+          index: 1,
+        });
+      }
+    })
+  },
+  onLaunch() {
+    console.error('第一次进来')
+    wx.setStorageSync('lastSceneNum', null)
+  }
 })

+ 254 - 240
pages/shared/shared.js

@@ -1,241 +1,255 @@
-// pages/shared/shared.js
-const api = require('../../config/api.js');
-const util = require('../../utils/util.js');
-const atob = require('../../utils/atob')
-
-
-Page({
-
-  /**
-   * 页面的初始数据
-   */
-  data: {
-    shared_img: '',
-    recommend_text: '',
-    editShowStatus: false,
-    loadHot: false
-  },
-
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad: async function (options) {
-    let { companyName, vrLink, id ,type} = options
-    console.log(vrLink)
-    vrLink = atob(vrLink)
-    console.log(vrLink)
-    this.vrLink = vrLink + `?id=${id}&type=${type}`
-    this.companyName = companyName
-    
-    
-
-    let data = await this.getBrandDetail(id,type)
-    this.sceneUrl = data.sceneUrl
-    this.shareCodeImg = data.shareWxQrCode
-
-    this.setData({
-      shared_img: data.appListPicUrl || 'https://plaza.4dkankan.com/statics/img/pic_bg@2x.png',
-      layoutHeight: wx.getSystemInfoSync().windowHeight - 170
-    })
-    const query = wx.createSelectorQuery()
-    query.select('.canvas').boundingClientRect().exec(res => {
-      this.canvas_width = res[0].width
-      this.canvas_height = res[0].height
-      this.drawImage()
-    })
-  },
-
-  getCompanyDetail () {
-    // CompanyApi.getCompanyDetail(this.companyId).then(res => {
-    //   console.log(res, 'company')
-    //   this.setData({
-    //     company: res.data
-    //   })
-    // })
-  },
-  showEdit () {
-    this.setData({
-      editShowStatus: true
-    })
-  },
-  hideEdit () {
-    this.setData({
-      editShowStatus: false
-    })
-  },
-  bindinput (e) {
-    const { value } = e.detail
-    value.substr(0,25)
-    this.setData({
-      recommend_text: value
-    })
-  },
-  onShareAppMessage () {
-    console.log(this.vrLink)
-    return {
-      path:  this.vrLink,
-      imageUrl: this.data.shared_img
-    }
-  },
-  copyLink () {
-    wx.setClipboardData({
-      data: decodeURIComponent(this.sceneUrl),
-      success (res) {
-        wx.showToast({
-          title: '复制成功',
-        })
-      }
-    })
-  },
-  
-  getBrandDetail: async function (id, type,cb) {
-    let res = await util.request(api.BrandDetail, { id: id,type:type })
-    return res.data.brand
-  },
-  savePhoto () {
-    wx.saveImageToPhotosAlbum({
-      filePath: this.data.img_url ,
-      success(res) {
-        wx.showModal({
-          title: '图片保存成功',
-          content: '图片成功保存到相册了,去发圈噻~',
-          showCancel: false,
-          confirmText: '好哒',
-          confirmColor: '#72B9C3',
-          success: (res) => {
-            if (res.confirm) {
-            }
-          }
-        })
-      }
-    })
-  },
-  async drawImage(recommend_text) {
-    this.context = wx.createCanvasContext('content')
-    this.context.lineJoin = 'miter'
-    this.context.font = 'bold 15px sans-serif'
-    this.context.setFillStyle('#fff')
-    this.context.fillRect(0, 0, this.canvas_width, this.canvas_height)
-    const dpr = wx.getSystemInfoSync().pixelRatio
-    let cover = await this.downloadFile(this.data.shared_img)
-    if (this.shareCodeImg) {
-      var shareCode = await this.downloadFile(this.shareCodeImg)
-    } else {
-      var shareCode = null
-    }
-    
-    const img_width = this.canvas_width * 0.8644,
-          img_height = this.canvas_width * 0.8644
-        const left = (this.canvas_width - img_width) / 2
-        // 画圆弧矩形
-        this.strokeRoundRect((this.canvas_width - img_width) / 2, (this.canvas_width - img_width) / 2, img_width, img_height, 4)
-        this.context.clip()
-        this.context.drawImage(cover, 0, 0, img_width, img_height)
-        this.context.restore()
-        this.context.fillStyle = '#131D34'
-        this.context.font = 'normal bold 15px sans-serif'
-        this.context.fillText(this.companyName, left, img_width + left + this.canvas_height * 15 / 460 + 21)
-        this.context.restore()
-        this.context.font = 'normal 300 13px sans-serif'
-        this.context.fillStyle = '#79868F'
-        let recommend_text1, recommend_text2
-        if (recommend_text) {
-          recommend_text1 = recommend_text.slice(0,11)
-          recommend_text2 = recommend_text.slice(11)
-        }
-        this.context.fillText(recommend_text1 || '我的个性推荐语', left, img_width + left + this.canvas_height * 15 / 460 + 18 + 21)
-        if (recommend_text2) {
-          this.context.font = 'normal 300 13px sans-serif'
-          this.context.fillStyle = '#79868F'
-          this.context.fillText(recommend_text2 || '我的个性推荐语', left, img_width + left + this.canvas_height * 15 / 460 + 18 + 21 + 21)
-        }
-        this.context.font = 'normal bold 12px sans-serif'
-        this.context.fillStyle = '#000'
-        shareCode && this.context.drawImage(shareCode, left, img_width + left + this.canvas_height * 92 / 460 + 10, 60, 60)
-        this.context.fillText('为爱筑家', left + 80, img_width + left + this.canvas_height * 92 / 460 + 20)
-        this.context.fillText('满足您对家的一切美好想象', left + 80, img_width + left + this.canvas_height * 92 / 460 + 40)
-        this.context.font = 'normal 300 12px sans-serif'
-        this.context.fillStyle = '#000'
-        this.context.fillText('长按识别二维码  进入店铺', left + 80, img_width + left + this.canvas_height * 140 / 460 + 17)
-
-        this.context.draw(false, () => {
-          wx.canvasToTempFilePath({
-            x: 0,
-            y: 0,
-            width: this.canvas_width,
-            height: this.canvas_height,
-            canvasId: 'content',
-            success: (res) => {
-              this.setData({
-                img_url: res.tempFilePath
-              })
-              
-              setTimeout(() => {
-                this.setData({loadHot: true})
-              }, 100)
-            }
-          })
-        })
-        this.context.fill()
-        this.context.restore()
-        
-  },
-  submitRecommend() {
-    this.drawImage(this.data.recommend_text)
-    this.hideEdit()
-  },
-  strokeRoundRect(x, y, width, height, radius, /*optional*/ lineWidth, /*optional*/ strokeColor) {
-    //圆的直径必然要小于矩形的宽高          
-    if (2 * radius > width || 2 * radius > height) {
-      return false;
-    }
-
-    this.context.save();
-    this.context.translate(x, y);
-    //绘制圆角矩形的各个边  
-    this.drawRoundRectPath(width, height, radius);
-    this.context.lineWidth = 0; //若是给定了值就用给定的值否则给予默认值2  
-    this.context.strokeStyle = strokeColor || "#fff";
-    this.context.stroke();
-
-  },
-  drawRoundRectPath(width, height, radius) {
-    this.context.beginPath(0);
-    //从右下角顺时针绘制,弧度从0到1/2PI  
-    this.context.arc(width - radius, height - radius, radius, 0, Math.PI / 2);
-
-    //矩形下边线  
-    this.context.lineTo(radius, height);
-
-    //左下角圆弧,弧度从1/2PI到PI  
-    this.context.arc(radius, height - radius, radius, Math.PI / 2, Math.PI);
-
-    //矩形左边线  
-    this.context.lineTo(0, radius);
-
-    //左上角圆弧,弧度从PI到3/2PI  
-    this.context.arc(radius, radius, radius, Math.PI, Math.PI * 3 / 2);
-
-    //上边线  
-    this.context.lineTo(width - radius, 0);
-
-    //右上角圆弧  
-    this.context.arc(width - radius, radius, radius, Math.PI * 3 / 2, Math.PI * 2);
-
-    //右边线  
-    this.context.lineTo(width, height - radius);
-    this.context.closePath();
-  },
-  downloadFile (url) {
-    return new Promise(resolve => {
-      wx.downloadFile({
-        url: url,
-        success (res) {
-          resolve(res.tempFilePath)
-        }
-      })
-    })
-  },
-
-
+// pages/shared/shared.js
+const api = require('../../config/api.js');
+const util = require('../../utils/util.js');
+const atob = require('../../utils/atob')
+
+
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    shared_img: '',
+    recommend_text: '',
+    editShowStatus: false,
+    loadHot: false
+  },
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: async function (options) {
+    let {
+      companyName,
+      vrLink,
+      id,
+      type
+    } = options
+    console.log(vrLink)
+    vrLink = atob(vrLink)
+    console.log(vrLink)
+    this.vrLink = vrLink + `?id=${id}&type=${type}`
+    this.companyName = companyName
+
+
+
+    let data = await this.getBrandDetail(id, type)
+    this.sceneUrl = data.sceneUrl
+    this.shareCodeImg = data.shareWxQrCode
+    
+    this.setData({
+      shared_img: data.appListPicUrl || 'https://plaza.4dkankan.com/statics/img/pic_bg@2x.png',
+      layoutHeight: wx.getSystemInfoSync().windowHeight - 170
+    })
+    const query = wx.createSelectorQuery()
+    query.select('.canvas').boundingClientRect().exec(res => {
+      this.canvas_width = res[0].width
+      this.canvas_height = res[0].height
+      this.drawImage()
+    })
+  },
+
+  getCompanyDetail() {
+    // CompanyApi.getCompanyDetail(this.companyId).then(res => {
+    //   console.log(res, 'company')
+    //   this.setData({
+    //     company: res.data
+    //   })
+    // })
+  },
+  showEdit() {
+    this.setData({
+      editShowStatus: true
+    })
+  },
+  hideEdit() {
+    this.setData({
+      editShowStatus: false
+    })
+  },
+  bindinput(e) {
+    const {
+      value
+    } = e.detail
+    value.substr(0, 25)
+    this.setData({
+      recommend_text: value
+    })
+  },
+  onShareAppMessage() {
+    console.log(this.vrLink)
+    return {
+      path: this.vrLink,
+      imageUrl: this.data.shared_img
+    }
+  },
+  copyLink() {
+    wx.setClipboardData({
+      data: decodeURIComponent(this.sceneUrl),
+      success(res) {
+        wx.showToast({
+          title: '复制成功',
+        })
+      }
+    })
+  },
+
+  getBrandDetail: async function (id, type, cb) {
+    let res = await util.request(api.BrandDetail, {
+      id: id,
+      type: type
+    })
+    return res.data.brand
+  },
+  savePhoto() {
+    wx.saveImageToPhotosAlbum({
+      filePath: this.data.img_url,
+      success(res) {
+        wx.showModal({
+          title: '图片保存成功',
+          content: '图片成功保存到相册了,去发圈噻~',
+          showCancel: false,
+          confirmText: '好哒',
+          confirmColor: '#72B9C3',
+          success: (res) => {
+            if (res.confirm) {}
+          }
+        })
+      }
+    })
+  },
+  async drawImage(recommend_text) {
+    this.context = wx.createCanvasContext('content')
+    this.context.lineJoin = 'miter'
+    this.context.font = 'bold 15px sans-serif'
+    this.context.setFillStyle('#fff')
+    this.context.fillRect(0, 0, this.canvas_width, this.canvas_height)
+    const dpr = wx.getSystemInfoSync().pixelRatio
+    let cover = await this.downloadFile(this.data.shared_img)
+    if (this.shareCodeImg) {
+      var shareCode = await this.downloadFile(this.shareCodeImg)
+    } else {
+      var shareCode = null
+    }
+
+    const img_width = this.canvas_width * 0.8644,
+      img_height = this.canvas_width * 0.8644
+    const left = (this.canvas_width - img_width) / 2
+    // 画圆弧矩形
+    this.strokeRoundRect((this.canvas_width - img_width) / 2, (this.canvas_width - img_width) / 2, img_width, img_height, 4)
+    this.context.clip()
+    this.context.drawImage(cover, 0, 0, img_width, img_height)
+    this.context.restore()
+    this.context.fillStyle = '#131D34'
+    this.context.font = 'normal bold 15px sans-serif'
+    this.context.fillText(this.companyName, left, img_width + left + this.canvas_height * 15 / 460 + 21)
+    this.context.restore()
+    this.context.font = 'normal 300 13px sans-serif'
+    this.context.fillStyle = '#79868F'
+    let recommend_text1, recommend_text2
+    if (recommend_text) {
+      recommend_text1 = recommend_text.slice(0, 11)
+      recommend_text2 = recommend_text.slice(11)
+    }
+    this.context.fillText(recommend_text1 || '我的个性推荐语', left, img_width + left + this.canvas_height * 15 / 460 + 18 + 21)
+    if (recommend_text2) {
+      this.context.font = 'normal 300 13px sans-serif'
+      this.context.fillStyle = '#79868F'
+      this.context.fillText(recommend_text2 || '我的个性推荐语', left, img_width + left + this.canvas_height * 15 / 460 + 18 + 21 + 21)
+    }
+    this.context.font = 'normal bold 12px sans-serif'
+    this.context.fillStyle = '#000'
+    shareCode && this.context.drawImage(shareCode, left, img_width + left + this.canvas_height * 92 / 460 + 10, 60, 60)
+    this.context.fillText('为爱筑家', left + 80, img_width + left + this.canvas_height * 92 / 460 + 20)
+    this.context.fillText('满足您对家的一切美好想象', left + 80, img_width + left + this.canvas_height * 92 / 460 + 40)
+    this.context.font = 'normal 300 12px sans-serif'
+    this.context.fillStyle = '#000'
+    this.context.fillText('长按识别二维码  进入店铺', left + 80, img_width + left + this.canvas_height * 140 / 460 + 17)
+
+    this.context.draw(false, () => {
+      wx.canvasToTempFilePath({
+        x: 0,
+        y: 0,
+        width: this.canvas_width,
+        height: this.canvas_height,
+        canvasId: 'content',
+        success: (res) => {
+          this.setData({
+            img_url: res.tempFilePath
+          })
+
+          setTimeout(() => {
+            this.setData({
+              loadHot: true
+            })
+          }, 100)
+        }
+      })
+    })
+    this.context.fill()
+    this.context.restore()
+
+  },
+  submitRecommend() {
+    this.drawImage(this.data.recommend_text)
+    this.hideEdit()
+  },
+  strokeRoundRect(x, y, width, height, radius, /*optional*/ lineWidth, /*optional*/ strokeColor) {
+    //圆的直径必然要小于矩形的宽高          
+    if (2 * radius > width || 2 * radius > height) {
+      return false;
+    }
+
+    this.context.save();
+    this.context.translate(x, y);
+    //绘制圆角矩形的各个边  
+    this.drawRoundRectPath(width, height, radius);
+    this.context.lineWidth = 0; //若是给定了值就用给定的值否则给予默认值2  
+    this.context.strokeStyle = strokeColor || "#fff";
+    this.context.stroke();
+
+  },
+  drawRoundRectPath(width, height, radius) {
+    this.context.beginPath(0);
+    //从右下角顺时针绘制,弧度从0到1/2PI  
+    this.context.arc(width - radius, height - radius, radius, 0, Math.PI / 2);
+
+    //矩形下边线  
+    this.context.lineTo(radius, height);
+
+    //左下角圆弧,弧度从1/2PI到PI  
+    this.context.arc(radius, height - radius, radius, Math.PI / 2, Math.PI);
+
+    //矩形左边线  
+    this.context.lineTo(0, radius);
+
+    //左上角圆弧,弧度从PI到3/2PI  
+    this.context.arc(radius, radius, radius, Math.PI, Math.PI * 3 / 2);
+
+    //上边线  
+    this.context.lineTo(width - radius, 0);
+
+    //右上角圆弧  
+    this.context.arc(width - radius, radius, radius, Math.PI * 3 / 2, Math.PI * 2);
+
+    //右边线  
+    this.context.lineTo(width, height - radius);
+    this.context.closePath();
+  },
+  downloadFile(url) {
+    return new Promise(resolve => {
+      wx.downloadFile({
+        url: url,
+        success(res) {
+          resolve(res.tempFilePath)
+        }
+      })
+    })
+  },
+
+
 })