Enzo 5 years ago
parent
commit
705257c30c
  1. 5
      common/scene.js
  2. 3
      main.js
  3. 16
      pages/center/invite.vue
  4. 30
      pages/goodsDetail/index.vue
  5. 14
      pages/index/index.vue
  6. 4
      pages/route/index.vue

5
common/scene.js

@ -0,0 +1,5 @@
// 分享相关场景值
export const V2_GOODS_SHAREBUTTON = "101";
export const V2_GOODS_SHAREPOSTER = "102";
export const V2_HOME_SHAREBUTTON = "103";
export const V2_INVITE_SHAREPOSTER = "104";

3
main.js

@ -2,6 +2,7 @@ import Vue from 'vue'
import App from './App'
import mixin from '@/common/mixin.js';
import * as API from '@/common/api.js';
import * as $scene from '@/common/scene.js';
import * as $shared from '@/common/shared.js';
import { uploadFile } from '@/common/uploadFile.js'
@ -12,6 +13,8 @@ Vue.mixin(mixin);
// 将API注入全局
Vue.prototype.API = API;
// 场景值
Vue.prototype.$scene = $scene;
// 全局共享方法
Vue.prototype.$shared = $shared;

16
pages/center/invite.vue

@ -77,12 +77,13 @@
},
getWxCode() {
let userInfo = uni.getStorageSync('userinfo') || {};
const token = this.$shared.createToken();
const token = this.$shared.createToken({user_id: userInfo.id});
let options = {
route: 'home',
pt: 2,
id: 2,
share_id: userInfo.id
share_id: userInfo.id,
scene_code: this.$scene.V2_INVITE_SHAREPOSTER
}
this.generateKooken(token, options); // token
@ -97,6 +98,17 @@
}
})
},
generateKooken(token, options){
options.version = this.API.VERSION;
let values = JSON.stringify(options);
values = encodeURIComponent(values);
this.$http(this.API.API_WAREHOUSE_SET, {
key: token,
value: values
}).then(res => {
console.log("res", token, res);
});
},
//
getwxCodeImg() {
var imgSrc = this.wxCode; //base64

30
pages/goodsDetail/index.vue

@ -142,7 +142,8 @@
backgroundImg: '',
goodShare: '',
s_id: '',
isShowButtonCount: 0
isShowButtonCount: 0,
userInfo: {}
}
},
computed: {
@ -155,7 +156,8 @@
onLoad(options) {
this.goods_id = options.id;
this.pt = options.pt || 1;
this.s_id = options.share_id || ''
this.s_id = options.share_id || '';
this.userInfo = uni.getStorageSync('userinfo') || {};
this.getGoodsDetail();
},
methods: {
@ -218,13 +220,16 @@
})
},
getWxCode() {
let userInfo = uni.getStorageSync('userinfo') || {};
const token = this.$shared.createToken();
const token = this.$shared.createToken({
user_id: this.userInfo.id,
goods_id: this.goods_id
});
let options = {
route: 'goods',
pt: 2,
id: this.goods_id,
share_id: userInfo.id
share_id: this.userInfo.id,
scene_code: this.$scene.V2_GOODS_SHAREPOSTER
}
this.generateKooken(token, options); // token
@ -475,7 +480,9 @@
},
// token
generateKooken(token, options){
options.version = this.API.VERSION;
let values = JSON.stringify(options);
values = encodeURIComponent(values);
this.$http(this.API.API_WAREHOUSE_SET, {
key: token,
value: values
@ -485,11 +492,15 @@
}
},
onShareAppMessage() {
const token = this.$shared.createToken();
const token = this.$shared.createToken({
user_id: this.userInfo.id,
goods_id: this.goods_id
});
let goods = this.goods_detail;
let options = {
id: goods.id,
route: 'goods'
route: 'goods',
scene_code: this.$scene.V2_GOODS_SHAREPOSTER
}
this.generateKooken(token, options); // token
@ -818,7 +829,8 @@
width: 80%;
height: 80%;
position: fixed;
top: 50rpx;
// top: 50rpx;
top: 140rpx;
left: 50%;
margin-left: -40%;
z-index: 100;
@ -832,7 +844,7 @@
line-height: 80rpx;
text-align: center;
position: fixed;
bottom: 50rpx;
bottom: 100rpx;
left: 10%;
background: rgba(254, 153, 3, 1);
color: #fff;

14
pages/index/index.vue

@ -192,6 +192,17 @@
onRefresherrefresh(){
this.isRefresher = true;
this.getCategoryList({type: 'scrollRefresh'});
},
generateKooken(token, options){
options.version = this.API.VERSION;
let values = JSON.stringify(options);
values = encodeURIComponent(values);
this.$http(this.API.API_WAREHOUSE_SET, {
key: token,
value: values
}).then(res => {
console.log("res", token, res);
});
}
},
// page
@ -209,7 +220,8 @@
},
onShareAppMessage(){
const token = this.$shared.createToken();
let options = {route: 'home'};
const scene_code = this.$scene.V2_HOME_SHAREBUTTON;
let options = {route: 'home', scene_code};
this.generateKooken(token, options); // token
let shareInfo = {

4
pages/route/index.vue

@ -25,7 +25,9 @@
getTokenValue(token){
this.$http(this.API.API_WAREHOUSE_GET, {key: token}).then(res => {
console.log("getTokenValue", res);
let options = JSON.parse(res.data);
let options = decodeURIComponent(res.data);
options = JSON.parse(options);
console.log("options", options)
this.routeToPage(options);
}).catch(err => {
// token

Loading…
Cancel
Save