Skip to content

Commit

Permalink
增加分销二维码及转发
Browse files Browse the repository at this point in the history
  • Loading branch information
gooking committed Mar 15, 2019
1 parent 7277640 commit 8d67a94
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 16 deletions.
4 changes: 2 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
version: "6.5.0",
note: '增加三级分销功能',
version: "6.5.1",
note: '增加分销二维码及转发',
subDomain: "tz", // 如果你的域名是: https://api.it120.cc/abcd 那么这里只要填写 abcd
appid: "wxa46b09d413fbcaff", // 您的小程序的appid,购物单功能需要使用
shareProfile: '百款精品商品,总有一款适合您' // 首页转发的时候话术
Expand Down
54 changes: 47 additions & 7 deletions pages/fx/apply-status.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const app = getApp()
const CONFIG = require('../../config.js')
const WXAPI = require('../../wxapi/main')
const regeneratorRuntime = require('../../utils/runtime')

Page({

Expand All @@ -8,7 +10,8 @@ Page({
*/
data: {
applyStatus: -2, // -1 表示未申请,0 审核中 1 不通过 2 通过
applyInfo: {}
applyInfo: {},
qrcode: '/images/fx.png'
},

/**
Expand All @@ -28,28 +31,56 @@ Page({
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
async onShow() {
const _this = this
const userDetail = await WXAPI.userDetail(wx.getStorageSync('token'))
WXAPI.fxApplyProgress(wx.getStorageSync('token')).then(res => {
let applyStatus = -1
let applyStatus = userDetail.data.base.isSeller ? 2 : -1
if (res.code == 2000) {
app.goLoginPageTimeOut()
return
}
if (res.code === 700) {
_this.setData({
applyStatus: -1
applyStatus: applyStatus
})
}
if (res.code === 0) {
if (userDetail.data.base.isSeller) {
applyStatus = 2
} else {
applyStatus = res.data.status
}
_this.setData({
applyStatus: res.data.status,
applyStatus: applyStatus,
applyInfo: res.data
})
}
if (applyStatus == 2) {
_this.fetchQrcode()
}
})
},
fetchQrcode(){
const _this = this
wx.showLoading({
title: '加载中',
mask: true
})
WXAPI.wxaQrcode({
scene: 'inviter_id=' + wx.getStorageSync('uid'),
page: 'pages/index/index',
is_hyaline: true,
expireHours: 1
}).then(res => {
wx.hideLoading()
if (res.code == 0) {
_this.setData({
qrcode: res.data
})
}
})
},

/**
* 生命周期函数--监听页面隐藏
*/
Expand Down Expand Up @@ -82,7 +113,16 @@ Page({
* 用户点击右上角分享
*/
onShareAppMessage: function () {

return {
title: '"' + wx.getStorageSync('mallName') + '" ' + CONFIG.shareProfile,
path: '/pages/index/index?inviter_id=' + wx.getStorageSync('uid'),
success: function (res) {
// 转发成功
},
fail: function (res) {
// 转发失败
}
}
},
bindSave: function (e) {
WXAPI.addTempleMsgFormid({
Expand Down
8 changes: 3 additions & 5 deletions pages/fx/apply-status.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
</view>

<view class='noApply' wx:if="{{applyStatus == 2}}">
<form bindsubmit="goShop" report-submit="true">
<image class="logo" src="/images/fx.png" mode="widthFix" />
<view class="profile">恭喜您,您已经是一名合格的分销商!</view>
<button type="primary" class="mini-btn" formType="submit">去商城逛逛</button>
</form>
<image class="logo" src="{{qrcode}}" mode="widthFix" />
<view class="profile">扫码关注您的专属推广码,或者转发邀请好友</view>
<button type="primary" open-type="share" class="mini-btn">转发</button>
</view>
10 changes: 8 additions & 2 deletions pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ Page({
selectCurrent: e.index
})
},
onLoad: function() {
var that = this
onLoad: function(e) {
const that = this
if (e && e.scene) {
const scene = decodeURIComponent(e.scene)
if (scene) {
wx.setStorageSync('referrer', scene.substring(11))
}
}
wx.setNavigationBarTitle({
title: wx.getStorageSync('mallName')
})
Expand Down
3 changes: 3 additions & 0 deletions pages/my/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<view class="my-item" wx:if="{{!apiUserInfoMap.base.isSeller}}">
<navigator url="/pages/fx/apply-status" hover-class="navigator-hover">成为分销商</navigator>
</view>
<view class="my-item" wx:if="{{apiUserInfoMap.base.isSeller}}">
<navigator url="/pages/fx/apply-status" hover-class="navigator-hover">分销中心</navigator>
</view>
<view class="my-item" wx:if="{{apiUserInfoMap.base.isSeller}}">
<navigator url="/pages/fx/members" hover-class="navigator-hover">我的团队</navigator>
</view>
Expand Down
3 changes: 3 additions & 0 deletions wxapi/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,8 @@ module.exports = {
},
fxCommisionLog: (data) => {
return request('/saleDistribution/commision/log', true, 'post', data)
},
wxaQrcode: (data) => {
return request('/qrcode/wxa/unlimit', true, 'post', data)
}
}

0 comments on commit 8d67a94

Please sign in to comment.