二维码分享功能
This commit is contained in:
parent
ed9a8ccd88
commit
3ac990eb63
|
|
@ -10,9 +10,9 @@ export default {
|
|||
title: '加载中'
|
||||
})
|
||||
// request 触发前拼接 url
|
||||
// args.url = 'https://www.opsoul.com' + args.url;
|
||||
args.url = 'https://www.opsoul.com' + args.url;
|
||||
// args.url = 'http://192.168.2.42:80' + args.url;
|
||||
args.url = 'http://127.0.0.1:80' + args.url;
|
||||
// args.url = 'http://127.0.0.1:80' + args.url;
|
||||
if (args.data) {
|
||||
args.data.deptId = globalData.deptId;
|
||||
args.data.from = globalData.from;
|
||||
|
|
@ -172,7 +172,7 @@ export default {
|
|||
})
|
||||
return res[1].data;
|
||||
},
|
||||
async updateUserPhone(params = {}) {
|
||||
async updateUser(params = {}) {
|
||||
let res = await uni.request({
|
||||
url: '/customer/update',
|
||||
method: 'POST',
|
||||
|
|
@ -181,9 +181,16 @@ export default {
|
|||
// 更新用户信息的方法顺便更新本地缓存
|
||||
if (res[1].data.code === 0) {
|
||||
let userInfo = this.getCurUserInfo();
|
||||
userInfo.phone = params.phone;
|
||||
userInfo.account = params.account;
|
||||
uni.setStorageSync('userProfile', userInfo);
|
||||
let wxGetUserRes = await this.qryUserInfo(userInfo.openId);
|
||||
let newUserInfo;
|
||||
if (wxGetUserRes.data) {
|
||||
newUserInfo = {
|
||||
...wxGetUserRes.data,
|
||||
wxLoginCode: userInfo.wxLoginCode
|
||||
}
|
||||
}
|
||||
console.log(newUserInfo)
|
||||
uni.setStorageSync('userProfile', newUserInfo);
|
||||
}
|
||||
return res[1].data;
|
||||
},
|
||||
|
|
@ -198,7 +205,7 @@ export default {
|
|||
}
|
||||
if (phoneRes && phoneRes.data) {
|
||||
let userInfo = this.getCurUserInfo();
|
||||
await this.updateUserPhone({
|
||||
await this.updateUser({
|
||||
customerId: userInfo.customerId,
|
||||
account: phoneRes.data,
|
||||
phone: phoneRes.data
|
||||
|
|
@ -213,6 +220,19 @@ export default {
|
|||
let userProfile = uni.getStorageSync('userProfile');
|
||||
return userProfile;
|
||||
},
|
||||
async getCurUserNoCache() {
|
||||
let userInfo = this.getCurUserInfo();
|
||||
let wxGetUserRes = await this.qryUserInfo(userInfo.openId);
|
||||
if (!wxGetUserRes.data) {
|
||||
userInfo = null;
|
||||
} else {
|
||||
userInfo = {
|
||||
...wxGetUserRes.data,
|
||||
wxLoginCode: userInfo.wxLoginCode
|
||||
}
|
||||
}
|
||||
return userInfo;
|
||||
},
|
||||
getProductCategories(params = {}) {
|
||||
return uni.request({
|
||||
url: '/goods/deptcategory/app/list',
|
||||
|
|
@ -424,4 +444,12 @@ export default {
|
|||
})
|
||||
return res[1].data;
|
||||
},
|
||||
async getUnlimitedWxacode(params = {}) {
|
||||
let res = await uni.request({
|
||||
url: '/wx/unlimited/wxacode',
|
||||
method: 'POST',
|
||||
data: params
|
||||
})
|
||||
return res[1].data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
<view class="cu-avatar round middle-avatar first-avatar">
|
||||
<view class="cuIcon-formfill"></view>
|
||||
</view>
|
||||
<view class="flex flex-column-around text-left margin-left-sm text-white" @click="showPage('/pages/publish/publish-task')">
|
||||
<view class="flex flex-column-around text-left margin-left-sm text-white"
|
||||
@click="showPage('/pages/publish/publish-task')">
|
||||
<view class="text-xl">发布任务</view>
|
||||
<view>公司、家居家政雇佣上门服务</view>
|
||||
</view>
|
||||
|
|
@ -86,20 +87,78 @@
|
|||
moduleBarInfos: [],
|
||||
curPageCode: 'indexPage',
|
||||
isShowPublish: false,
|
||||
forwardingPageCode: null
|
||||
forwardingPageCode: null,
|
||||
curUserInfo: null,
|
||||
inByShare: false,
|
||||
inParam: null
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.loadData();
|
||||
onLoad(option) {
|
||||
if (option && option.scene) {
|
||||
let paraStr = decodeURIComponent(option.scene);
|
||||
let kvStrArr = paraStr.split("&");
|
||||
kvStrArr.forEach((kvStr) => {
|
||||
let kvArr = kvStr.split("=");
|
||||
option[kvArr[0]] = kvArr[1];
|
||||
});
|
||||
}
|
||||
this.inParam = option;
|
||||
this.loadData(option);
|
||||
},
|
||||
onShareAppMessage(e) {
|
||||
let shareInfo = null;
|
||||
if (e && e.target && e.target.dataset) {
|
||||
shareInfo = e.target.dataset.shareInfo;
|
||||
}
|
||||
if (!this.curUserInfo) {
|
||||
this.curUserInfo = this.$request.getCurUserNoCache();
|
||||
if (!this.curUserInfo) {
|
||||
uni.showToast({
|
||||
title: '请前往“我的”完成登录',
|
||||
icon: 'none'
|
||||
})
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!shareInfo) {
|
||||
shareInfo = {
|
||||
title: '家政服务就找工圈子',
|
||||
path: '/pages/index/index?distributor=' + this.curUserInfo.customerId,
|
||||
imageUrl: 'http://gqz.opsoul.com/sys/group-selfie.png'
|
||||
}
|
||||
}
|
||||
return shareInfo;
|
||||
},
|
||||
methods: {
|
||||
async loadData() {
|
||||
async loadData(option) {
|
||||
this.moduleBarInfos = await this.$api.data('moduleBarInfos');
|
||||
this.curUserInfo = this.$request.getCurUserInfo();
|
||||
// 更新分销人信息
|
||||
if (option && option.distributor) {
|
||||
let loginRes = await this.authLogin();
|
||||
if (!loginRes) {
|
||||
this.inByShare = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.inByShare = false;
|
||||
let res = await this.$request.updateUser({
|
||||
customerPlace: option.distributor,
|
||||
customerId: this.curUserInfo.customerId
|
||||
});
|
||||
if (res && res.code === 0) {
|
||||
this.inParam = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
reloadForwardPage() {
|
||||
this.getCurPageInfo({
|
||||
curPageCode: this.forwardingPageCode
|
||||
})
|
||||
if (this.inByShare) {
|
||||
this.loadData(this.inParam);
|
||||
} else {
|
||||
this.getCurPageInfo({
|
||||
curPageCode: this.forwardingPageCode
|
||||
})
|
||||
}
|
||||
},
|
||||
async getCurPageInfo(data) {
|
||||
let pageCode = data.curPageCode;
|
||||
|
|
|
|||
|
|
@ -209,10 +209,10 @@
|
|||
<view class="cuIcon-servicefill text-olive"></view>
|
||||
<text>联系客服</text>
|
||||
</view> -->
|
||||
<!-- <view class="cu-item">
|
||||
<view class="cu-item" @click="showAppInviteQrcode">
|
||||
<view class="cuIcon-qr_code text-green"></view>
|
||||
<text>二维码分享</text>
|
||||
</view> -->
|
||||
</view>
|
||||
<!-- <view class="cu-item">
|
||||
<view class="cuIcon-moneybagfill text-cyan"></view>
|
||||
<text>钱包</text>
|
||||
|
|
@ -251,13 +251,39 @@
|
|||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<!-- app二维码分享 -->
|
||||
<view class="cu-modal" :class="appShareQrcodeModal?'show':''">
|
||||
<view class="cu-dialog bg-white">
|
||||
<view class="cu-bar bg-white justify-end">
|
||||
<view class="content">小程序邀请二维码</view>
|
||||
<view class="action" @click="hideModal" data-modal="appShareQrcodeModal">
|
||||
<text class="cuIcon-close text-red"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="padding-tb-sm">
|
||||
<image :src="'data:image/png;base64,' + appQrcode" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="text-center padding">
|
||||
<view class="padding-bottom-sm text-lg">请通过扫码或分享链接给好友进行邀请</view>
|
||||
<button class="cu-btn bg-main-color shadow-blur" open-type="share">
|
||||
<text class="cuIcon-share"></text>
|
||||
<text>分享链接给好友</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import appInviteQrcode from '@/pages/my/app-invite-qrcode.vue';
|
||||
|
||||
export default {
|
||||
name: 'personal-center',
|
||||
components: {},
|
||||
// components: {
|
||||
// appInviteQrcode
|
||||
// },
|
||||
data() {
|
||||
return {
|
||||
pageContentTop: this.CustomBar,
|
||||
|
|
@ -302,7 +328,10 @@
|
|||
type: -1,
|
||||
name: '已完成'
|
||||
}],
|
||||
productOrderType: 1
|
||||
productOrderType: 1,
|
||||
|
||||
appQrcode: '',
|
||||
appShareQrcodeModal: false
|
||||
}
|
||||
},
|
||||
onReady() {
|
||||
|
|
@ -342,6 +371,13 @@
|
|||
url: '/pages/my/apply-operator'
|
||||
})
|
||||
},
|
||||
async showAppInviteQrcode() {
|
||||
let res = await this.$request.getUnlimitedWxacode({
|
||||
scene: "distributor=" + this.curUserInfo.customerId
|
||||
});
|
||||
this.appQrcode = res.data;
|
||||
this.appShareQrcodeModal = true;
|
||||
},
|
||||
showPage(pageUrl) {
|
||||
if (pageUrl) {
|
||||
uni.navigateTo({
|
||||
|
|
@ -353,6 +389,9 @@
|
|||
title: '功能开发中'
|
||||
})
|
||||
}
|
||||
},
|
||||
hideModal(e) {
|
||||
this[e.currentTarget.dataset.modal] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
<template>
|
||||
<!-- 报价/客户支付模态框 -->
|
||||
<view class="cu-modal" :class="show?'show':''">
|
||||
<view class="cu-dialog bg-white">
|
||||
<view class="cu-bar bg-white justify-end">
|
||||
<view class="content">小程序邀请二维码</view>
|
||||
<view class="action" @click="hideModal">
|
||||
<text class="cuIcon-close text-red"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="padding-tb-sm">
|
||||
<image :src="'data:image/png;base64,' + url"></image>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view>请通过扫码或分享链接给好友进行邀请</view>
|
||||
<button class="cu-btn bg-main-color shadow-blur" open-type="share" :data-shareInfo="shareInfo"
|
||||
style="width: 100%;">
|
||||
<text class="cuIcon-share"></text>
|
||||
<text>分享链接给好友</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
nama: 'app-invite-qrcode',
|
||||
data() {
|
||||
return {
|
||||
url: '',
|
||||
show: false,
|
||||
shareTemplate: {
|
||||
title: '家政服务就找工圈子',
|
||||
path: '/pages/index/index?customerPlace=',
|
||||
imageUrl: 'http://gqz.opsoul.com/sys/group-selfie.png'
|
||||
},
|
||||
shareInfo: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
showModal(url) {
|
||||
this.show = true;
|
||||
this.url = url;
|
||||
let curUserInfo = this.$request.getCurUserInfo();
|
||||
if (curUserInfo.customerId && curUserInfo.customerId > 0) {
|
||||
let path = this.shareTemplate.path + curUserInfo.customerId;
|
||||
this.shareInfo = {
|
||||
...this.shareTemplate,
|
||||
path: path
|
||||
}
|
||||
}
|
||||
},
|
||||
hideModal() {
|
||||
this.shareInfo = null;
|
||||
this.show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Loading…
Reference in New Issue