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

16
pages/center/invite.vue

@ -77,12 +77,13 @@
}, },
getWxCode() { getWxCode() {
let userInfo = uni.getStorageSync('userinfo') || {}; let userInfo = uni.getStorageSync('userinfo') || {};
const token = this.$shared.createToken();
const token = this.$shared.createToken({user_id: userInfo.id});
let options = { let options = {
route: 'home', route: 'home',
pt: 2, pt: 2,
id: 2, id: 2,
share_id: userInfo.id
share_id: userInfo.id,
scene_code: this.$scene.V2_INVITE_SHAREPOSTER
} }
this.generateKooken(token, options); // token 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() { getwxCodeImg() {
var imgSrc = this.wxCode; //base64 var imgSrc = this.wxCode; //base64

30
pages/goodsDetail/index.vue

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

14
pages/index/index.vue

@ -192,6 +192,17 @@
onRefresherrefresh(){ onRefresherrefresh(){
this.isRefresher = true; this.isRefresher = true;
this.getCategoryList({type: 'scrollRefresh'}); 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 // page
@ -209,7 +220,8 @@
}, },
onShareAppMessage(){ onShareAppMessage(){
const token = this.$shared.createToken(); 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 this.generateKooken(token, options); // token
let shareInfo = { let shareInfo = {

4
pages/route/index.vue

@ -25,7 +25,9 @@
getTokenValue(token){ getTokenValue(token){
this.$http(this.API.API_WAREHOUSE_GET, {key: token}).then(res => { this.$http(this.API.API_WAREHOUSE_GET, {key: token}).then(res => {
console.log("getTokenValue", 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); this.routeToPage(options);
}).catch(err => { }).catch(err => {
// token // token

Loading…
Cancel
Save