小程序新增页面分享绑定推荐人

This commit is contained in:
sugar1569 2019-04-02 17:29:40 +08:00
parent 1735d62f71
commit ca23e0e6ec
2 changed files with 86 additions and 89 deletions

View File

@ -20,10 +20,10 @@ class RoutineQrcode extends ModelBasic {
* @param int $thirdId * @param int $thirdId
* @return object * @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_type'] = $thirdType;
$data['third_id'] = $thirdId; $data['third_id'] = $thirdId;
$data['status'] = 0; $data['status'] = 1;
$data['add_time'] = time(); $data['add_time'] = time();
$data['page'] = $page; $data['page'] = $page;
$data['url_time'] = ''; $data['url_time'] = '';
@ -70,5 +70,30 @@ class RoutineQrcode extends ModelBasic {
return self::where('id',$id)->where('status',1)->field($field)->find(); 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);
}
} }

View File

@ -84,65 +84,64 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
// console.log(options); var that = this;
// return ; var pages = getCurrentPages();
app.globalData.openPages = '/pages/product-con/index?id=' + options.id; if (pages.length != 2 && !options.hasOwnProperty('id')) return false;
app.setBarColor(); app.globalData.openPages = '/pages/product-con/index?id=' + options.id + '&scene=' + app.globalData.uid;
var that = this; app.setBarColor();
app.setUserInfo(); that.setData({ id: options.id });
that.getCartCount(); that.getProductInfo();
that.setData({ },
id: options.id getProductInfo:function(){
}) var that = this;
var header = { var header = { 'content-type': 'application/x-www-form-urlencoded' };
'content-type': 'application/x-www-form-urlencoded', wx.request({
}; url: app.globalData.url + '/routine/auth_api/details?uid=' + app.globalData.uid,
wx.request({ method: 'POST',
url: app.globalData.url + '/routine/auth_api/details?uid=' + app.globalData.uid, data: { id: that.data.id },
method: 'POST', header: header,
data:{ success: function (res) {
id:that.data.id if (res.data.code == 200) {
}, var image = "productSelect.image";
header: header, var store_name = "productSelect.store_name";
success: function (res) { var price = "productSelect.price";
if(res.data.code == 200){ var unique = "productSelect.unique";
var image = "productSelect.image"; var stock = "productSelect.stock";
var store_name = "productSelect.store_name"; that.setData({
var price = "productSelect.price"; storeInfo: res.data.data.storeInfo,
var unique = "productSelect.unique"; storeKeyWord: res.data.data.storeInfo.keyword.split(","),
var stock = "productSelect.stock"; similarity: res.data.data.similarity,
that.setData({ productAttr: res.data.data.productAttr,
storeInfo: res.data.data.storeInfo, productValue: res.data.data.productValue,
storeKeyWord: res.data.data.storeInfo.keyword.split(","), reply: res.data.data.reply,
similarity: res.data.data.similarity, replyCount: res.data.data.replyCount,
productAttr: res.data.data.productAttr, description: res.data.data.storeInfo.description,
productValue: res.data.data.productValue, collect: res.data.data.storeInfo.userCollect,
reply: res.data.data.reply, [image]: res.data.data.storeInfo.image,
replyCount: res.data.data.replyCount, [stock]: res.data.data.storeInfo.stock,
description: res.data.data.storeInfo.description, [store_name]: res.data.data.storeInfo.store_name,
collect:res.data.data.storeInfo.userCollect, [price]: res.data.data.storeInfo.price,
[image]: res.data.data.storeInfo.image, [unique]: ''
[stock]: res.data.data.storeInfo.stock, })
[store_name]: res.data.data.storeInfo.store_name, that.getCartCount();
[price]: res.data.data.storeInfo.price, that.downloadFilestoreImage();
[unique]: '' that.downloadFilePromotionCode();
}) WxParse.wxParse('description', 'html', that.data.description, that, 0);
that.downloadFilestoreImage(); } else {
that.downloadFilePromotionCode(); if (app.globalData.uid == null) {//是否存在用户信息,如果不存在跳转到首页
WxParse.wxParse('description', 'html', that.data.description, that, 0); setTimeout(function () { wx.navigateTo({ url: '/pages/loading/loading' }) }, 1500)
}else{ } else {
wx.showToast({ wx.showToast({
title: res.data.msg, title: res.data.msg,
icon: 'none', icon: 'none',
duration: 1000 duration: 1000
}) });
setTimeout(function(){ setTimeout(function () { wx.navigateBack({}); }, 1200);
wx.navigateBack({});
},1200)
}
} }
}) }
}
})
}, },
listenerActionSheet: function () { listenerActionSheet: function () {
this.setData({ this.setData({
@ -257,7 +256,7 @@ Page({
downloadFilePromotionCode:function(){ downloadFilePromotionCode:function(){
var that = this; var that = this;
wx.request({ 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', method: 'GET',
data: { id: that.data.id, }, data: { id: that.data.id, },
success: function (res) { success: function (res) {
@ -287,7 +286,6 @@ Page({
}) })
that.setData({ canvasStatus: true }); that.setData({ canvasStatus: true });
const arr2 = ['/images/posterbackgd.png', that.data.storeImage, that.data.PromotionCode]; const arr2 = ['/images/posterbackgd.png', that.data.storeImage, that.data.PromotionCode];
console.log(arr2);
if (arr2[2] == '') { if (arr2[2] == '') {
wx.request({ 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_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 () { parameterShow: function () {
var that = this; var that = this;
if (that.data.productSelect.unique != ''){ if (that.data.productSelect.unique != ''){
@ -879,7 +851,7 @@ Page({
}) })
return { return {
title: that.data.productSelect.store_name, title: that.data.productSelect.store_name,
path: app.globalData.openPages, path: app.globalData.openPages,
// imageUrl: that.data.url + that.data.product.image, // imageUrl: that.data.url + that.data.product.image,
success: function () { success: function () {
wx.showToast({ wx.showToast({