Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
130d27627a | ||
![]() |
9f64cad51b | ||
![]() |
6701261cbb | ||
![]() |
9f344bc60e |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gamemall",
|
"name": "gamemall",
|
||||||
"version": "0.0.2",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gamemall",
|
"name": "gamemall",
|
||||||
"version": "0.0.2",
|
"version": "1.0.0",
|
||||||
"description": "游戏电商小程序",
|
"description": "游戏电商小程序",
|
||||||
"main": "dist/app.js",
|
"main": "dist/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"description": "游戏电商小程序",
|
"description": "游戏电商小程序",
|
||||||
"setting": {
|
"setting": {
|
||||||
"urlCheck": false,
|
"urlCheck": true,
|
||||||
"es6": false,
|
"es6": false,
|
||||||
"postcss": false,
|
"postcss": false,
|
||||||
"minified": false,
|
"minified": false,
|
||||||
@ -10,7 +10,7 @@
|
|||||||
"checkInvalidKey": true
|
"checkInvalidKey": true
|
||||||
},
|
},
|
||||||
"compileType": "miniprogram",
|
"compileType": "miniprogram",
|
||||||
"appid": "wx815bf59d472c0a63",
|
"appid": "wx7d6509053659d9ed",
|
||||||
"projectname": "gamemall",
|
"projectname": "gamemall",
|
||||||
"miniprogramRoot": "dist/",
|
"miniprogramRoot": "dist/",
|
||||||
"simulatorType": "wechat",
|
"simulatorType": "wechat",
|
||||||
@ -32,7 +32,7 @@
|
|||||||
"list": []
|
"list": []
|
||||||
},
|
},
|
||||||
"miniprogram": {
|
"miniprogram": {
|
||||||
"current": 0,
|
"current": 2,
|
||||||
"list": [
|
"list": [
|
||||||
{
|
{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
@ -47,6 +47,17 @@
|
|||||||
"pathName": "pages/buyvip",
|
"pathName": "pages/buyvip",
|
||||||
"query": "token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjNmUxYjk3NDA5MGY5NTYxM2M3YjgxOSIsImFjY291bnRfaWQiOiI2MDAxXzgwMDNfb0pZYXA1WlZSV0RGRm9Qd09GcGllQmVNRkVocyIsInNlc3Npb25faWQiOiIxNTUwNzU0Njg5XzE1NTA3MTc1OTRfYjA5YTVmOWYxODM0NDFmOWUxMDk1MGJmOTUyZTRjMjFfNTcyOWRkOWYyMzQ5NzdlM2IwMGNjOGFjYWRjMjFiOTQiLCJpYXQiOjE1NTA3NTQ2ODl9.GkUGGb2vwTE1xgZ-UKwl6Tfs3NFawE2V3ZAH91_syY4",
|
"query": "token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjNmUxYjk3NDA5MGY5NTYxM2M3YjgxOSIsImFjY291bnRfaWQiOiI2MDAxXzgwMDNfb0pZYXA1WlZSV0RGRm9Qd09GcGllQmVNRkVocyIsInNlc3Npb25faWQiOiIxNTUwNzU0Njg5XzE1NTA3MTc1OTRfYjA5YTVmOWYxODM0NDFmOWUxMDk1MGJmOTUyZTRjMjFfNTcyOWRkOWYyMzQ5NzdlM2IwMGNjOGFjYWRjMjFiOTQiLCJpYXQiOjE1NTA3NTQ2ODl9.GkUGGb2vwTE1xgZ-UKwl6Tfs3NFawE2V3ZAH91_syY4",
|
||||||
"scene": null
|
"scene": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "io",
|
||||||
|
"pathName": "pages/io",
|
||||||
|
"query": "",
|
||||||
|
"scene": 1037,
|
||||||
|
"referrerInfo": {
|
||||||
|
"appId": "1231231",
|
||||||
|
"extraData": "{ \"data\": \"hello box\", \"isoffical\" : false }"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
34
src/app.wpy
34
src/app.wpy
@ -21,6 +21,8 @@
|
|||||||
import wepy from 'wepy'
|
import wepy from 'wepy'
|
||||||
import 'wepy-async-function'
|
import 'wepy-async-function'
|
||||||
import jcEvent from './common/jc-event';
|
import jcEvent from './common/jc-event';
|
||||||
|
import global from './common/global';
|
||||||
|
var g = require('./common/global').default;
|
||||||
|
|
||||||
let sdkManage = require('./jcfw/SDKManage');
|
let sdkManage = require('./jcfw/SDKManage');
|
||||||
|
|
||||||
@ -30,6 +32,7 @@ export default class extends wepy.app {
|
|||||||
'pages/index',
|
'pages/index',
|
||||||
'pages/product',
|
'pages/product',
|
||||||
'pages/buyvip',
|
'pages/buyvip',
|
||||||
|
'pages/io',
|
||||||
'pages/detail'
|
'pages/detail'
|
||||||
],
|
],
|
||||||
window: {
|
window: {
|
||||||
@ -43,18 +46,16 @@ export default class extends wepy.app {
|
|||||||
globalData = {
|
globalData = {
|
||||||
userInfo: null,
|
userInfo: null,
|
||||||
gameToken: null,
|
gameToken: null,
|
||||||
dataType: 'game'
|
dataType: 'game',
|
||||||
|
fromAppId: '',
|
||||||
|
extraData: {},
|
||||||
|
isPay: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
super()
|
super()
|
||||||
this.use('requestfix');
|
this.use('requestfix');
|
||||||
this.use('promisify');
|
this.use('promisify');
|
||||||
sdkManage.init();
|
|
||||||
sdkManage.Login(() => {
|
|
||||||
jcEvent.emit(jcEvent.events.NEED_UPDATE_CFG, {});
|
|
||||||
console.log('finish parse jcfw');
|
|
||||||
});
|
|
||||||
//全局拦截器
|
//全局拦截器
|
||||||
this.intercept('request', {
|
this.intercept('request', {
|
||||||
config(p) {
|
config(p) {
|
||||||
@ -89,10 +90,29 @@ export default class extends wepy.app {
|
|||||||
onShow(options) {
|
onShow(options) {
|
||||||
console.log('app.onShow');
|
console.log('app.onShow');
|
||||||
console.log(options);
|
console.log(options);
|
||||||
if (options.scene === 1037) {
|
let isoffical = g.env === 'product';
|
||||||
|
if (options.scene === 1037 || options.scene === 1038) {
|
||||||
let params = options.query;
|
let params = options.query;
|
||||||
this.globalData.gameToken = params.token;
|
this.globalData.gameToken = params.token;
|
||||||
this.globalData.dataType = params.dataType;
|
this.globalData.dataType = params.dataType;
|
||||||
|
if (options.referrerInfo) {
|
||||||
|
let referrerInfo = options.referrerInfo;
|
||||||
|
this.globalData.fromAppId = referrerInfo.appId;
|
||||||
|
this.globalData.extraData = referrerInfo.extraData;
|
||||||
|
isoffical = referrerInfo.extraData.isoffical
|
||||||
|
}
|
||||||
|
this.globalData.isPay = true;
|
||||||
|
} else {
|
||||||
|
this.globalData.isPay = false;
|
||||||
|
}
|
||||||
|
sdkManage.isoffical = isoffical;
|
||||||
|
g.env = isoffical ? 'product' : 'test';
|
||||||
|
if (!(sdkManage.session_id && sdkManage.account_id)) {
|
||||||
|
sdkManage.init();
|
||||||
|
sdkManage.Login(() => {
|
||||||
|
jcEvent.emit(jcEvent.events.LOGIN_FINISHED, {});
|
||||||
|
console.log('finish parse jcfw');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,8 @@ export default {
|
|||||||
'赛车', '动作游戏','策略战棋', '其他',
|
'赛车', '动作游戏','策略战棋', '其他',
|
||||||
'益智游戏', '体育游戏', '冒险游戏', '模拟战略',
|
'益智游戏', '体育游戏', '冒险游戏', '模拟战略',
|
||||||
'桌面游戏', '音乐游戏', '第一人称射击'
|
'桌面游戏', '音乐游戏', '第一人称射击'
|
||||||
]
|
],
|
||||||
|
payUrl: function(isOffice) {
|
||||||
|
return isOffice ? 'https://gamepay.kingsome.cn/webapp/index.php?c=Pay&a=aggregatePay':'https://gamepay-test.kingsome.cn/webapp/index.php?c=Pay&a=aggregatePay';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,19 +8,19 @@ export default {
|
|||||||
events[name] = [{self, cb}]
|
events[name] = [{self, cb}]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
remove (name, self) {
|
remove (name, target) {
|
||||||
let cbArr = events[name];
|
let cbArr = events[name];
|
||||||
if (Array.isArray(cbArr)) {
|
if (Array.isArray(cbArr)) {
|
||||||
events[name] = cbArr.filter(({target, cb}) => {
|
events[name] = cbArr.filter(({self, cb}) => {
|
||||||
return target !== self
|
return self !== target
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emit (name, data) {
|
emit (name, data) {
|
||||||
let cbArr = events[name];
|
let cbArr = events[name];
|
||||||
if (Array.isArray(cbArr)) {
|
if (Array.isArray(cbArr)) {
|
||||||
cbArr.map(({target, cb}) => {
|
cbArr.map(({self, cb}) => {
|
||||||
cb.call(target, data)
|
cb.call(self, data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
var jcfw = require('./jcfw');
|
var jcfw = require('./jcfw');
|
||||||
var jcgamelog = jcfw.gamelog;
|
|
||||||
var jcshare = jcfw.share;
|
var jcshare = jcfw.share;
|
||||||
var g = require('../common/global').default;
|
var g = require('../common/global').default;
|
||||||
|
|
||||||
var SDKManage = function() {
|
var SDKManage = function() {
|
||||||
this.isoffical = g.env === 'product';
|
this.isoffical = g.env === 'product';
|
||||||
this.gameId = 8003;
|
this.gameId = 9002;
|
||||||
this.hasLogin = false;
|
this.hasLogin = false;
|
||||||
this.vision = '1.0.0';
|
this.vision = '1.0.0';
|
||||||
this.ChannelId = 6001;
|
this.ChannelId = 6001;
|
||||||
|
this.gamelog = jcfw.gamelog;
|
||||||
this.init = function() {
|
this.init = function() {
|
||||||
jcfw.init(this.ChannelId, this.gameId, this.isoffical);
|
jcfw.init(this.ChannelId, this.gameId, this.isoffical);
|
||||||
};
|
};
|
||||||
@ -47,6 +47,7 @@ var SDKManage = function() {
|
|||||||
console.log(res);
|
console.log(res);
|
||||||
wx.setStorageSync('account', res);
|
wx.setStorageSync('account', res);
|
||||||
self.account_id = res.account_id;
|
self.account_id = res.account_id;
|
||||||
|
self.session_id = res.session_id;
|
||||||
self.doLogin();
|
self.doLogin();
|
||||||
},
|
},
|
||||||
(neterr, logicerr, errmsg) => {
|
(neterr, logicerr, errmsg) => {
|
||||||
@ -67,7 +68,14 @@ var SDKManage = function() {
|
|||||||
};
|
};
|
||||||
var cbf = function(res) {
|
var cbf = function(res) {
|
||||||
console.log('getGameConfig fail');
|
console.log('getGameConfig fail');
|
||||||
|
if (!self.cfgTryCount) {
|
||||||
|
self.cfgTryCount = 1;
|
||||||
|
} else {
|
||||||
|
self.cfgTryCount += 1;
|
||||||
|
}
|
||||||
|
if (self.cfgTryCount < 10) {
|
||||||
self.getGameConfig();
|
self.getGameConfig();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
jcfw.cloud.initConfig(cb, cbf);
|
jcfw.cloud.initConfig(cb, cbf);
|
||||||
// jcfw.getConfig('',cb,cbf);
|
// jcfw.getConfig('',cb,cbf);
|
||||||
|
@ -124,7 +124,7 @@
|
|||||||
this.gid = decodeURIComponent(params.gid);
|
this.gid = decodeURIComponent(params.gid);
|
||||||
}
|
}
|
||||||
onShow() {
|
onShow() {
|
||||||
jcEvent.on(jcEvent.events.NEED_UPDATE_CFG, this, data => {
|
jcEvent.on(jcEvent.events.LOGIN_FINISHED, this, data => {
|
||||||
this.loadCfg();
|
this.loadCfg();
|
||||||
this.$apply();
|
this.$apply();
|
||||||
})
|
})
|
||||||
|
133
src/pages/io.wpy
Normal file
133
src/pages/io.wpy
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
<style lang="less">
|
||||||
|
.qrimg_content {
|
||||||
|
display: flex;
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 300px;
|
||||||
|
top: 0;
|
||||||
|
justify-content: center;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
#myQrcode{
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<template>
|
||||||
|
<view class="qrimg_content">
|
||||||
|
<canvas style="width: 300px; height: 300px;" canvas-id="myQrcode"></canvas>
|
||||||
|
</view>
|
||||||
|
<view class="qrimg_content">
|
||||||
|
<image class="qrimg" @tap="imageTap" src="{{imgData}}" show-menu-by-longpress style="width: 300px; height:300px;"></image>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import wepy from 'wepy';
|
||||||
|
import cfg from '../mixins/cfg';
|
||||||
|
import http from '../utils/http';
|
||||||
|
import g from '../common/global';
|
||||||
|
import jcEvent from '../common/jc-event';
|
||||||
|
|
||||||
|
let sdkManage = require('../jcfw/SDKManage');
|
||||||
|
|
||||||
|
export default class ProductPage extends wepy.page {
|
||||||
|
mixins = [cfg];
|
||||||
|
components = {
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
navigationBarTitleText: '购买产品'
|
||||||
|
};
|
||||||
|
data = {
|
||||||
|
imgData: ''
|
||||||
|
};
|
||||||
|
methods = {
|
||||||
|
imageTap: function(e) {
|
||||||
|
wepy.previewImage({
|
||||||
|
current: this.imgData,
|
||||||
|
urls: [this.imgData]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
async onLoad(params) {
|
||||||
|
console.log('io page onload,', params);
|
||||||
|
if (this.$parent.globalData.isPay) {
|
||||||
|
if (sdkManage.session_id) {
|
||||||
|
this.prePay();
|
||||||
|
} else {
|
||||||
|
jcEvent.on(jcEvent.events.LOGIN_FINISHED, this, data => {
|
||||||
|
this.prePay();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wepy.reLaunch({
|
||||||
|
url: '/pages/index'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onShow(){
|
||||||
|
|
||||||
|
}
|
||||||
|
async prePay() {
|
||||||
|
wepy.showLoading({
|
||||||
|
title: '支付中'
|
||||||
|
});
|
||||||
|
this.payData = this.$parent.globalData.extraData;
|
||||||
|
if (this.payData) {
|
||||||
|
let url = `${g.payUrl(this.payData.isoffical)}&session_id=${sdkManage.session_id}&account_id=${sdkManage.account_id}&data=${encodeURIComponent(this.payData.data)}`
|
||||||
|
sdkManage.gamelog.logButtonClick('pay', {data: this.payData}, 'payBegin');
|
||||||
|
try {
|
||||||
|
let res = await http.get(url);
|
||||||
|
if (res.errcode === 0) {
|
||||||
|
let payInfo = JSON.parse(res.pay_str);
|
||||||
|
this.orderId = res.orderid;
|
||||||
|
console.log(payInfo);
|
||||||
|
this.beginPay(payInfo);
|
||||||
|
}
|
||||||
|
this.$apply();
|
||||||
|
} catch (err) {
|
||||||
|
sdkManage.gamelog.logButtonClick('pay', {data: this.payData, errMsg: 'requestPayment:fail prepay'}, 'parError');
|
||||||
|
wepy.hideLoading();
|
||||||
|
this.backToApp('requestPayment:fail prepay');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wepy.hideLoading();
|
||||||
|
sdkManage.gamelog.logButtonClick('pay', {errMsg: 'requestPayment:fail no pay data'}, 'parError');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
beginPay(payInfo) {
|
||||||
|
let self = this;
|
||||||
|
wx.requestPayment({
|
||||||
|
'timeStamp': payInfo.timeStamp,
|
||||||
|
'nonceStr': payInfo.nonceStr,
|
||||||
|
'package': payInfo.package,
|
||||||
|
'signType': payInfo.signType,
|
||||||
|
'paySign': payInfo.paySign,
|
||||||
|
complete: (res) => {
|
||||||
|
wepy.hideLoading();
|
||||||
|
console.log('支付结果:', res);
|
||||||
|
if (res.errMsg === 'requestPayment:ok') {
|
||||||
|
console.log('支付成功')
|
||||||
|
sdkManage.gamelog.logButtonClick('pay', {data: self.payData, orderId: self.orderId}, 'parSuccess');
|
||||||
|
} else if (res.errMsg === 'requestPayment:fail cancel' || res.errMsg === 'requestPayment:cancel') {
|
||||||
|
sdkManage.gamelog.logButtonClick('pay', {data: self.payData, orderId: self.orderId, errMsg: res.errMsg}, 'parError');
|
||||||
|
} else {
|
||||||
|
console.log('支付失败');
|
||||||
|
sdkManage.gamelog.logButtonClick('pay', {data: self.payData, orderId: self.orderId, errMsg: res.errMsg}, 'parError');
|
||||||
|
}
|
||||||
|
self.backToApp(res.errMsg);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
backToApp(errMsg) {
|
||||||
|
wepy.navigateBackMiniProgram({
|
||||||
|
extraData: {
|
||||||
|
payData: errMsg,
|
||||||
|
orderid: this.orderId
|
||||||
|
},
|
||||||
|
complete: (res) => {
|
||||||
|
console.log('navigateBackMiniProgram success, now to index');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -81,7 +81,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
async onLoad(params) {
|
async onLoad(params) {
|
||||||
jcEvent.on(jcEvent.events.NEED_UPDATE_CFG, this, data => {
|
jcEvent.on(jcEvent.events.LOGIN_FINISHED, this, data => {
|
||||||
this.loadCfg();
|
this.loadCfg();
|
||||||
this.$apply();
|
this.$apply();
|
||||||
})
|
})
|
||||||
|
@ -15,7 +15,7 @@ const post = (url, data, header) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Ajax = (url, method, data, header) => {
|
const Ajax = (url, method, data, header) => {
|
||||||
url = g.apiBase + url
|
url = url.startsWith('http') ? url : g.apiBase + url;
|
||||||
header = header || {}
|
header = header || {}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user