From ca23e0e6ec0ab2ae5c69d2779ac61b082ddb372d Mon Sep 17 00:00:00 2001 From: sugar1569 Date: Tue, 2 Apr 2019 17:29:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=88=86=E4=BA=AB=E7=BB=91=E5=AE=9A=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../routine/model/routine/RoutineQrcode.php | 29 +++- view/crmebN/pages/product-con/index.js | 146 +++++++----------- 2 files changed, 86 insertions(+), 89 deletions(-) diff --git a/application/routine/model/routine/RoutineQrcode.php b/application/routine/model/routine/RoutineQrcode.php index c7ce2330..00357228 100644 --- a/application/routine/model/routine/RoutineQrcode.php +++ b/application/routine/model/routine/RoutineQrcode.php @@ -20,10 +20,10 @@ class RoutineQrcode extends ModelBasic { * @param int $thirdId * @return object */ - public static function setRoutineQrcodeForever($thirdId = 0,$thirdType = 'spread',$page = '',$imgUrl = ''){ + public static function setRoutineQrCodeForever($thirdId = 0,$thirdType = 'spread',$page = '',$imgUrl = ''){ $data['third_type'] = $thirdType; $data['third_id'] = $thirdId; - $data['status'] = 0; + $data['status'] = 1; $data['add_time'] = time(); $data['page'] = $page; $data['url_time'] = ''; @@ -70,5 +70,30 @@ class RoutineQrcode extends ModelBasic { return self::where('id',$id)->where('status',1)->field($field)->find(); } + /** + * TODO 根据用户编号和二维码类型查看分销二维码是否存在 + * @param int $thirdId + * @param string $thirdType + * @return int|string + * @throws \think\Exception + */ + public static function getRoutineQrCodeCount($thirdId = 0,$thirdType = 'spread'){ + return self::where('third_id',$thirdId)->where('third_type',$thirdType)->count(); + } + + /** + * TODO 根据用户编号和二维码类型获取分销二维码 + * @param int $thirdId + * @param string $thirdType + * @return bool|mixed|object + * @throws \think\Exception + */ + public static function getRoutineQrCode($thirdId = 0,$thirdType = 'spread',$page = '',$imgUrl = ''){ + if(!$thirdId) return false; + $count = self::getRoutineQrCodeCount($thirdId,$thirdType); + if($count) return self::where('third_id',$thirdId)->where('third_type',$thirdType)->find(); + else return self::setRoutineQrCodeForever($thirdId,$thirdType,$page,$imgUrl); + } + } \ No newline at end of file diff --git a/view/crmebN/pages/product-con/index.js b/view/crmebN/pages/product-con/index.js index 9f5da24c..dea07f44 100644 --- a/view/crmebN/pages/product-con/index.js +++ b/view/crmebN/pages/product-con/index.js @@ -84,65 +84,64 @@ Page({ /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { - // console.log(options); - // return ; - app.globalData.openPages = '/pages/product-con/index?id=' + options.id; - app.setBarColor(); - var that = this; - app.setUserInfo(); - that.getCartCount(); - that.setData({ - id: options.id - }) - var header = { - 'content-type': 'application/x-www-form-urlencoded', - }; - wx.request({ - url: app.globalData.url + '/routine/auth_api/details?uid=' + app.globalData.uid, - method: 'POST', - data:{ - id:that.data.id - }, - header: header, - success: function (res) { - if(res.data.code == 200){ - var image = "productSelect.image"; - var store_name = "productSelect.store_name"; - var price = "productSelect.price"; - var unique = "productSelect.unique"; - var stock = "productSelect.stock"; - that.setData({ - storeInfo: res.data.data.storeInfo, - storeKeyWord: res.data.data.storeInfo.keyword.split(","), - similarity: res.data.data.similarity, - productAttr: res.data.data.productAttr, - productValue: res.data.data.productValue, - reply: res.data.data.reply, - replyCount: res.data.data.replyCount, - description: res.data.data.storeInfo.description, - collect:res.data.data.storeInfo.userCollect, - [image]: res.data.data.storeInfo.image, - [stock]: res.data.data.storeInfo.stock, - [store_name]: res.data.data.storeInfo.store_name, - [price]: res.data.data.storeInfo.price, - [unique]: '' - }) - that.downloadFilestoreImage(); - that.downloadFilePromotionCode(); - WxParse.wxParse('description', 'html', that.data.description, that, 0); - }else{ - wx.showToast({ - title: res.data.msg, - icon: 'none', - duration: 1000 - }) - setTimeout(function(){ - wx.navigateBack({}); - },1200) - } + onLoad: function (options) { + var that = this; + var pages = getCurrentPages(); + if (pages.length != 2 && !options.hasOwnProperty('id')) return false; + app.globalData.openPages = '/pages/product-con/index?id=' + options.id + '&scene=' + app.globalData.uid; + app.setBarColor(); + that.setData({ id: options.id }); + that.getProductInfo(); + }, + getProductInfo:function(){ + var that = this; + var header = { 'content-type': 'application/x-www-form-urlencoded' }; + wx.request({ + url: app.globalData.url + '/routine/auth_api/details?uid=' + app.globalData.uid, + method: 'POST', + data: { id: that.data.id }, + header: header, + success: function (res) { + if (res.data.code == 200) { + var image = "productSelect.image"; + var store_name = "productSelect.store_name"; + var price = "productSelect.price"; + var unique = "productSelect.unique"; + var stock = "productSelect.stock"; + that.setData({ + storeInfo: res.data.data.storeInfo, + storeKeyWord: res.data.data.storeInfo.keyword.split(","), + similarity: res.data.data.similarity, + productAttr: res.data.data.productAttr, + productValue: res.data.data.productValue, + reply: res.data.data.reply, + replyCount: res.data.data.replyCount, + description: res.data.data.storeInfo.description, + collect: res.data.data.storeInfo.userCollect, + [image]: res.data.data.storeInfo.image, + [stock]: res.data.data.storeInfo.stock, + [store_name]: res.data.data.storeInfo.store_name, + [price]: res.data.data.storeInfo.price, + [unique]: '' + }) + that.getCartCount(); + that.downloadFilestoreImage(); + that.downloadFilePromotionCode(); + WxParse.wxParse('description', 'html', that.data.description, that, 0); + } else { + if (app.globalData.uid == null) {//是否存在用户信息,如果不存在跳转到首页 + setTimeout(function () { wx.navigateTo({ url: '/pages/loading/loading' }) }, 1500) + } else { + wx.showToast({ + title: res.data.msg, + icon: 'none', + duration: 1000 + }); + setTimeout(function () { wx.navigateBack({}); }, 1200); } - }) + } + } + }) }, listenerActionSheet: function () { this.setData({ @@ -257,7 +256,7 @@ Page({ downloadFilePromotionCode:function(){ var that = this; wx.request({ - url: app.globalData.url + '/routine/auth_api/product_promotion_code?uid=' + app.globalData.uid, + url: app.globalData.url + '/routine/auth_api/product_promotion_routine_code?uid=' + app.globalData.uid, method: 'GET', data: { id: that.data.id, }, success: function (res) { @@ -287,7 +286,6 @@ Page({ }) that.setData({ canvasStatus: true }); const arr2 = ['/images/posterbackgd.png', that.data.storeImage, that.data.PromotionCode]; - console.log(arr2); if (arr2[2] == '') { wx.request({ url: app.globalData.url + '/routine/auth_api/product_promotion_code?uid=' + app.globalData.uid, @@ -413,32 +411,6 @@ Page({ }) } }, - goPhoto:function(){ - var that = this; - wx.showActionSheet({ - itemList: ['发送给朋友', '生成海报'], - success: function (res) { - if (res.tapIndex){ - wx.request({ - url: app.globalData.url + '/routine/auth_api/get_pages?uid=' + app.globalData.uid, - method: 'GET', - data: { - path: app.globalData.openPages, - productId: that.data.id - }, - success: function (res) { - console.log(res); - } - }) - }else{ - that.onShareAppMessage(); - } - }, - fail: function (res) { - console.log(res.errMsg) - } - }) - }, parameterShow: function () { var that = this; if (that.data.productSelect.unique != ''){ @@ -879,7 +851,7 @@ Page({ }) return { title: that.data.productSelect.store_name, - path: app.globalData.openPages, + path: app.globalData.openPages, // imageUrl: that.data.url + that.data.product.image, success: function () { wx.showToast({