Compare commits

..

No commits in common. "master" and "dev" have entirely different histories.
master ... dev

12 changed files with 123 additions and 906 deletions

View File

@ -1,102 +1,76 @@
{
"description": "游戏电商小程序",
"setting": {
"urlCheck": false,
"es6": false,
"postcss": false,
"preloadBackgroundData": false,
"minified": false,
"newFeature": true,
"coverView": true,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": false,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"useIsolateContext": true,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"showES6CompileOption": false
},
"compileType": "miniprogram",
"appid": "wx815bf59d472c0a63",
"projectname": "gamemall",
"miniprogramRoot": "dist/",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"plugin": {
"list": []
},
"game": {
"list": []
},
"miniprogram": {
"list": [
{
"id": 0,
"name": "product_page",
"pathName": "pages/product",
"query": "gid=7002058&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjN2Y1NWIyYzQ0NzVmMWMzMDg4YjcxOSIsImFjY291bnRfaWQiOiI2MDAxXzgwMDRfbzVGclg1WG45eHM4d1pmdHlSYVd4ZEVuQ2FyMCIsInNlc3Npb25faWQiOiIxNTUxODQ4ODgxXzE1NTE4NDg0NjVfNmFhZjNlMTQzNWMxNDNiODdkYzI0MWU2ZTQ0MGYwMmFfNjgxYzhiYWUxZGI0ODFiMDdkYmQxNzJjYmMwNDVlYWQiLCJpYXQiOjE1NTE4NDg4ODJ9.kdTs8UIGP9sxdZN7cpO047bBg69SBUQn6BMZ0Ndckgg",
"scene": null
},
{
"id": 1,
"name": "vip_page",
"pathName": "pages/buyvip",
"query": "token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjNmUxYjk3NDA5MGY5NTYxM2M3YjgxOSIsImFjY291bnRfaWQiOiI2MDAxXzgwMDNfb0pZYXA1WlZSV0RGRm9Qd09GcGllQmVNRkVocyIsInNlc3Npb25faWQiOiIxNTUwNzU0Njg5XzE1NTA3MTc1OTRfYjA5YTVmOWYxODM0NDFmOWUxMDk1MGJmOTUyZTRjMjFfNTcyOWRkOWYyMzQ5NzdlM2IwMGNjOGFjYWRjMjFiOTQiLCJpYXQiOjE1NTA3NTQ2ODl9.GkUGGb2vwTE1xgZ-UKwl6Tfs3NFawE2V3ZAH91_syY4",
"scene": null
},
{
"id": 2,
"name": "exchange-result",
"pathName": "pages/exchange-result",
"query": "",
"scene": 1037,
"referrerInfo": {
"appId": "4562388888889",
"extraData": "{ \t\"accountId\": \"6001_1004_oQmL74u7TBo94aGpKIGNCZD9rKew\", \t\"sessionId\": \"1566525470_1563178315_f37bcfd5c3b82fd28d00d18273e7f1a5_53c8e916459a621c1e5021fba99c9212\", \t\"gameId\": \"8002\", \t\"channelId\": \"6001\", \"recordId\": \"5d5fa7ea6f8cb82bc0195750\" }"
}
},
{
"id": 3,
"name": "pages/exchange-record",
"pathName": "pages/exchange-record",
"query": "",
"scene": 1037,
"referrerInfo": {
"appId": "12344",
"extraData": "{ \t\"accountId\": \"6001_1004_oQmL74u7TBo94aGpKIGNCZD9rKew\", \t\"sessionId\": \"1566525470_1563178315_f37bcfd5c3b82fd28d00d18273e7f1a5_53c8e916459a621c1e5021fba99c9212\", \t\"gameId\": \"8002\", \t\"channelId\": \"6001\", \"recordId\": \"5d5e81eedfd349387cace22c\" }"
}
},
{
"name": "普通支付",
"pathName": "pages/normal",
"query": "gname=武极天下&pname=首充6元礼包&price=600&sname=双线10服&uname=azwe&oid=1231231313&aid=123123",
"scene": 1037,
"referrerInfo": {
"appId": "wxf184833bbfdc3d78",
"extraData": "{}"
}
}
]
}
}
"description": "游戏电商小程序",
"setting": {
"urlCheck": false,
"es6": false,
"postcss": false,
"minified": false,
"newFeature": true,
"autoAudits": false,
"checkInvalidKey": true
},
"compileType": "miniprogram",
"appid": "wx815bf59d472c0a63",
"projectname": "gamemall",
"miniprogramRoot": "dist/",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"list": []
},
"miniprogram": {
"current": 2,
"list": [
{
"id": 0,
"name": "product_page",
"pathName": "pages/product",
"query": "gid=7002058&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjN2Y1NWIyYzQ0NzVmMWMzMDg4YjcxOSIsImFjY291bnRfaWQiOiI2MDAxXzgwMDRfbzVGclg1WG45eHM4d1pmdHlSYVd4ZEVuQ2FyMCIsInNlc3Npb25faWQiOiIxNTUxODQ4ODgxXzE1NTE4NDg0NjVfNmFhZjNlMTQzNWMxNDNiODdkYzI0MWU2ZTQ0MGYwMmFfNjgxYzhiYWUxZGI0ODFiMDdkYmQxNzJjYmMwNDVlYWQiLCJpYXQiOjE1NTE4NDg4ODJ9.kdTs8UIGP9sxdZN7cpO047bBg69SBUQn6BMZ0Ndckgg",
"scene": null
},
{
"id": 1,
"name": "vip_page",
"pathName": "pages/buyvip",
"query": "token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjNmUxYjk3NDA5MGY5NTYxM2M3YjgxOSIsImFjY291bnRfaWQiOiI2MDAxXzgwMDNfb0pZYXA1WlZSV0RGRm9Qd09GcGllQmVNRkVocyIsInNlc3Npb25faWQiOiIxNTUwNzU0Njg5XzE1NTA3MTc1OTRfYjA5YTVmOWYxODM0NDFmOWUxMDk1MGJmOTUyZTRjMjFfNTcyOWRkOWYyMzQ5NzdlM2IwMGNjOGFjYWRjMjFiOTQiLCJpYXQiOjE1NTA3NTQ2ODl9.GkUGGb2vwTE1xgZ-UKwl6Tfs3NFawE2V3ZAH91_syY4",
"scene": null
},
{
"id": 2,
"name": "exchange-result",
"pathName": "pages/exchange-result",
"query": "",
"scene": 1037,
"referrerInfo": {
"appId": "4562388888889",
"extraData": "{ \t\"accountId\": \"6001_1004_oQmL74u7TBo94aGpKIGNCZD9rKew\", \t\"sessionId\": \"1566525470_1563178315_f37bcfd5c3b82fd28d00d18273e7f1a5_53c8e916459a621c1e5021fba99c9212\", \t\"gameId\": \"8002\", \t\"channelId\": \"6001\", \"recordId\": \"5d5fa7ea6f8cb82bc0195750\" }"
}
},
{
"id": 3,
"name": "pages/exchange-record",
"pathName": "pages/exchange-record",
"query": "",
"scene": 1037,
"referrerInfo": {
"appId": "12344",
"extraData": "{ \t\"accountId\": \"6007_1004_D1A9357FB5975B61CDCB43B1AEE6C5D0\", \t\"sessionId\": \"1566525470_1563178315_f37bcfd5c3b82fd28d00d18273e7f1a5_53c8e916459a621c1e5021fba99c9212\", \t\"gameId\": \"8002\", \t\"channelId\": \"6001\", \"recordId\": \"5d5e81eedfd349387cace22c\" }"
}
}
]
}
}
}

View File

@ -1,64 +0,0 @@
{
"setting": {},
"condition": {
"plugin": {
"list": []
},
"game": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": [
{
"id": 0,
"name": "product_page",
"pathName": "pages/product",
"query": "gid=7002058&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjN2Y1NWIyYzQ0NzVmMWMzMDg4YjcxOSIsImFjY291bnRfaWQiOiI2MDAxXzgwMDRfbzVGclg1WG45eHM4d1pmdHlSYVd4ZEVuQ2FyMCIsInNlc3Npb25faWQiOiIxNTUxODQ4ODgxXzE1NTE4NDg0NjVfNmFhZjNlMTQzNWMxNDNiODdkYzI0MWU2ZTQ0MGYwMmFfNjgxYzhiYWUxZGI0ODFiMDdkYmQxNzJjYmMwNDVlYWQiLCJpYXQiOjE1NTE4NDg4ODJ9.kdTs8UIGP9sxdZN7cpO047bBg69SBUQn6BMZ0Ndckgg",
"scene": null
},
{
"id": 1,
"name": "vip_page",
"pathName": "pages/buyvip",
"query": "token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjNmUxYjk3NDA5MGY5NTYxM2M3YjgxOSIsImFjY291bnRfaWQiOiI2MDAxXzgwMDNfb0pZYXA1WlZSV0RGRm9Qd09GcGllQmVNRkVocyIsInNlc3Npb25faWQiOiIxNTUwNzU0Njg5XzE1NTA3MTc1OTRfYjA5YTVmOWYxODM0NDFmOWUxMDk1MGJmOTUyZTRjMjFfNTcyOWRkOWYyMzQ5NzdlM2IwMGNjOGFjYWRjMjFiOTQiLCJpYXQiOjE1NTA3NTQ2ODl9.GkUGGb2vwTE1xgZ-UKwl6Tfs3NFawE2V3ZAH91_syY4",
"scene": null
},
{
"id": 2,
"name": "exchange-result",
"pathName": "pages/exchange-result",
"query": "",
"scene": 1037,
"referrerInfo": {
"appId": "4562388888889",
"extraData": "{ \t\"accountId\": \"6001_1004_oQmL74u7TBo94aGpKIGNCZD9rKew\", \t\"sessionId\": \"1566525470_1563178315_f37bcfd5c3b82fd28d00d18273e7f1a5_53c8e916459a621c1e5021fba99c9212\", \t\"gameId\": \"8002\", \t\"channelId\": \"6001\", \"recordId\": \"5d5fa7ea6f8cb82bc0195750\" }"
}
},
{
"id": 3,
"name": "pages/exchange-record",
"pathName": "pages/exchange-record",
"query": "",
"scene": 1037,
"referrerInfo": {
"appId": "12344",
"extraData": "{ \t\"accountId\": \"6001_1004_oQmL74u7TBo94aGpKIGNCZD9rKew\", \t\"sessionId\": \"1566525470_1563178315_f37bcfd5c3b82fd28d00d18273e7f1a5_53c8e916459a621c1e5021fba99c9212\", \t\"gameId\": \"8002\", \t\"channelId\": \"6001\", \"recordId\": \"5d5e81eedfd349387cace22c\" }"
}
},
{
"name": "武极支付",
"pathName": "pages/normal",
"query": "pname=首充6元礼包&price=600&sname=双线10服&uname=azwe&aid=123123&pid=7&uid=zhl&sid=10000&openid=oSsQK41xNe4ZSJI76wwVE3aNA_jM",
"scene": 1037,
"referrerInfo": {
"appId": "wxf184833bbfdc3d78",
"extraData": "{}"
}
}
]
}
}
}

View File

@ -9,7 +9,7 @@
align-items: center;
justify-content: space-between;
box-sizing: border-box;
// width: 749rpx;
width: 749rpx;
overflow-x: hidden;
}
.hidden {
@ -31,7 +31,6 @@ export default class extends wepy.app {
'pages/product',
'pages/buyvip',
'pages/detail',
'pages/normal',
'pages/exchange-result',
'pages/exchange-record',
],
@ -56,7 +55,6 @@ export default class extends wepy.app {
sdkManage.init()
sdkManage.Login(() => {
jcEvent.emit(jcEvent.events.NEED_UPDATE_CFG, {})
jcEvent.emit(jcEvent.events.LOGIN_FINISHED, {})
console.log('finish parse jcfw')
})
//全局拦截器

BIN
src/assets/cry.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

@ -2,12 +2,11 @@ const env = process.env.NODE_ENV === 'production' ? 'product' : 'test'; //produc
export default {
env: env,
// apiBase: 'http://192.168.100.232',
apiBase: env === 'test' ? 'https://ghost-test.kingsome.cn' : 'https://ghost.kingsome.cn',
wjtxPayUrl: env === 'test' ? 'https://game1009proxy-test.kingsome.cn/webapp/index.php?c=Pay&a=preOrder' : 'https://game1009proxy.kingsome.cn/webapp/index.php?c=Pay&a=preOrder',
apiBase: env === 'test'? 'https://ghost-test.kingsome.cn' : 'https://ghost.kingsome.cn',
version: '1.0.1',
gameTypes: ['射击', '格斗', '角色扮演', '动作角色扮演',
'赛车', '动作游戏', '策略战棋', '其他',
gameTypes: ['射击','格斗', '角色扮演','动作角色扮演',
'赛车', '动作游戏','策略战棋', '其他',
'益智游戏', '体育游戏', '冒险游戏', '模拟战略',
'桌面游戏', '音乐游戏', '第一人称射击'
]
};
}

View File

@ -9,7 +9,6 @@ var SDKManage = function() {
this.hasLogin = false;
this.vision = '1.0.0';
this.ChannelId = 6001;
this.gamelog = jcgamelog;
this.init = function() {
jcfw.init(this.ChannelId, this.gameId, this.isoffical);
};
@ -48,7 +47,6 @@ var SDKManage = function() {
console.log(res);
wx.setStorageSync('account', res);
self.account_id = res.account_id;
self.session_id = res.session_id;
self.doLogin();
},
(neterr, logicerr, errmsg) => {
@ -69,14 +67,7 @@ var SDKManage = function() {
};
var cbf = function(res) {
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.getConfig('',cb,cbf);

View File

@ -1,26 +1,19 @@
<style lang="less">
.container {
background-color: #fafafa;
min-height: 100vh;
.records {
width: 100%;
padding: 24rpx;
.record {
display: flex;
align-items: center;
height: 200rpx;
margin: 32rpx;
padding: 24rpx;
border-radius: 16rpx;
background-color: #fcecd8;
overflow: hidden;
box-shadow: rgba(0, 0, 0, 0.1) 0 6rpx 12rpx;
justify-content: space-between;
height: 180rpx;
margin: 24rpx;
border: 1px solid #f0f0f0;
.item-img-wrap {
width: 160rpx;
height: 160rpx;
flex-shrink: 0;
border-radius: 32rpx;
height: 100%;
width: 180rpx;
.item-img {
width: 100%;
height: 100%;
@ -28,90 +21,33 @@
}
.item-desc {
display: flex;
flex-direction: column;
flex: 1;
height: 160rpx;
margin-left: 32rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
.item-title {
color: #f31f0f;
font-size: 40rpx;
font-weight: 700;
box-sizing: border-box;
height: 100%;
margin-left: 36rpx;
padding-top: 24rpx;
.item-title,
.code {
display: block;
line-height: 1.2;
}
.item-date,
.item-used,
.item-code {
color: #707070;
font-size: 24rpx;
}
.item-date {
flex: 1;
margin-top: 24rpx;
}
.item-code {
justify-items: flex-end;
.code {
margin-top: 36rpx;
font-size: 28rpx;
color: #666;
max-width: 240rpx;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}
.btn-copy,
.btn-use {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
color: #fff;
.btn-copy {
width: 180rpx;
height: 100%;
border-left: 1px solid #f0f0f0;
line-height: 180rpx;
text-align: center;
font-size: 32rpx;
line-height: 120rpx;
background-color: #ff5d5d;
box-shadow: rgba(0, 0, 0, 0.2) 0 6rpx 12rpx;
}
.btn-disabled {
background-color: #d8d8d8 !important;
}
}
}
.mask {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.3);
.modal {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 80%;
height: 180rpx;
margin: auto;
padding: 48rpx;
background-color: #fcecd8;
border-radius: 32rpx;
box-shadow: rgba(0, 0, 0, 0.3) 0 6rpx 12rpx;
.btn-area {
text-align: right;
}
.btn-submit {
background-color: #ff5d5d;
}
.btn-submit,
.btn-reset {
margin: 32rpx 16rpx 32rpx 0;
border: none;
}
.ipt-tel {
margin-top: 16rpx;
border-bottom: 1px solid #ccc;
}
}
}
@ -135,76 +71,18 @@
></image>
</view>
<view class="item-desc">
<text class="item-text item-title">{{item.gift_info.gift_name}}</text>
<text class="item-text item-date">{{item.time}}</text>
<text
class="item-text item-code"
wx:if="{{item.gift_info.type === 0}}"
>{{item.code}}</text>
<text
class="item-text item-code"
wx:if="{{item.gift_info.type === 1}}"
>{{item.used === false ? '未使用' : '已使用'}}</text>
<text
class="item-text item-code"
wx:if="{{item.gift_info.type === 2}}"
>{{item.used === false ? '等待工作人员与您联系' : '已使用'}}</text>
<text class="item-title">{{item.gift_info.gift_name}}</text>
<text class="code">{{item.code}}</text>
</view>
<view
class="btn-copy"
@tap="copy"
data-index="{{index}}"
wx:if="{{item.gift_info.type === 0}}"
>复制</view>
<view
class="btn-use {{item.used ? 'btn-disabled' : ''}}"
@tap="use"
data-index="{{index}}"
wx:if="{{item.gift_info.type === 1 || item.gift_info.type === 2}}"
>兑换</view>
</view>
</repeat>
</view>
<view
class="tip"
wx:if="{{records.length === 0}}"
>暂无兑换记录</view>
<view
class="mask"
id="mask"
@tap="closeModal"
wx:if="{{modalVisible}}"
>
<view class="modal">
<form
bindsubmit="formSubmit"
bindreset="formReset"
>
<view class="section">
<view class="section__title">手机号:</view>
<input
name="tel"
placeholder="输入手机号码"
class="ipt-tel"
value="{{user_tel}}"
/>
</view>
<view class="btn-area">
<button
form-type="submit"
class="btn-submit"
size="mini"
type="primary"
>提交</button>
<button
form-type="reset"
class="btn-reset"
size="mini"
>重置</button>
</view>
</form>
</view>
</view>
<view class="tip" wx:if="{{records.length === 0}}">暂无兑换记录</view>
</view>
</template>
@ -219,10 +97,6 @@ export default class ExchangeRecord extends wepy.page {
data = {
records: [],
modalVisible: false,
curRecordId: '',
curRecordIdx: '',
user_tel: ''
}
methods = {
@ -237,101 +111,18 @@ export default class ExchangeRecord extends wepy.page {
},
})
},
use(e) {
const used = this.records[e.target.dataset.index].used
if (used) {
// wx.showToast({
// icon: 'none',
// title: '不可重复兑换!',
// })
return
}
this.curRecordId = this.records[e.target.dataset.index].record_id
this.curRecordIdx = e.target.dataset.index
this.methods.openModal(this)
},
async formSubmit(e) {
try {
const reg = /^1\d{10}$/g
const tel = e.detail.value.tel
if (!reg.test(tel)) {
wx.showToast({
icon: 'none',
title: '请输入正确的手机号!',
})
return
}
const extraData = wepy.$instance.globalData.extraData
let url = ''
let type = this.records[this.curRecordIdx].gift_info.type
if (type === 1) {
url = '/api/gift/tel'
} else if (type === 2) {
url = '/api/gift/goods'
}
const res = await http.post(url, {
accountId: extraData.accountId,
sessionId: extraData.sessionId,
recordId: this.curRecordId,
phone: tel,
})
const data = res.data
if (res.errcode === 0) {
wx.setStorage({
key: 'tel',
data: tel,
})
if (type === 1) {
wx.showToast({
title: '兑换成功!',
})
} else if (type === 2) {
wx.showToast({
title: '信息提交成功!',
})
}
} else {
wx.showToast({
icon: 'none',
title: res.errmsg,
})
}
this.modalVisible = false
this.$apply()
} catch (err) {
const msg = err.data.errmsg || '失败'
wx.showToast({
icon: 'none',
title: msg,
})
}
},
openModal(ctx) {
ctx.modalVisible = true
ctx.user_tel = wx.getStorageSync('tel')
},
closeModal(e) {
if (e.target.id === 'mask') {
this.modalVisible = false
}
},
}
async onShow() {
try {
const extraData = wepy.$instance.globalData.extraData
const res = await http.get(
`/api/gift/records?accountId=${extraData.accountId}&gameId=${
extraData.gameId
}&channelId=${extraData.channelId}`
)
this.records = res.result || []
this.$apply()
} catch (err) {
console.log(err)
}
const extraData = wepy.$instance.globalData.extraData
const res = await http.get(
`/api/gift/records?accountId=${
extraData.accountId
}&gameId=${extraData.gameId}&channelId=${extraData.channelId}`
)
this.records = res.result
this.$apply()
console.log(this.records)
}
}
</script>

View File

@ -1,133 +0,0 @@
<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>

View File

@ -1,314 +0,0 @@
<template>
<view class="container">
<view class="weui-form-preview">
<view class="weui-form-preview__hd">
<view class="weui-form-preview__item">
<view class="weui-form-preview__label">付款金额</view>
<view class="weui-form-preview__value_in-hd">¥{{money}}</view>
</view>
</view>
<view class="weui-form-preview__bd">
<view class="weui-form-preview__item">
<view class="weui-form-preview__label">商品</view>
<view class="weui-form-preview__value">{{productName}}</view>
</view>
<view class="weui-form-preview__item">
<view class="weui-form-preview__label">区服</view>
<view class="weui-form-preview__value">{{svrName}}</view>
</view>
<view class="weui-form-preview__item">
<view class="weui-form-preview__label">角色名称</view>
<view class="weui-form-preview__value">{{uname}}</view>
</view>
<!-- <view class="weui-form-preview__item">-->
<!-- <view class="weui-form-preview__label">订单编号</view>-->
<!-- <view class="weui-form-preview__value">{{orderId}}</view>-->
<!-- </view>-->
</view>
<view class="weui-form-preview__ft">
<button class="weui-btn" type="primary" @tap="buy">购买</button>
<button class="weui-btn" type="default" @tap="cancelBuy">取消</button>
</view>
</view>
</view>
</template>
<script>
import wepy from 'wepy';
import jcEvent from '../common/jc-event';
import cfg from '../mixins/cfg';
import g from '../common/global';
import http from '../utils/http';
const sdkManage = require('../jcfw/SDKManage')
export default class NormalPage extends wepy.page {
mixins = [cfg];
components = {
};
config = {
navigationBarTitleText: '武极天下'
};
data = {
gid: '',
gameName: '武极天下',
productName: '',
svrName: '',
uname: '',
orderId: '',
price: 100,
account: '',
money: '',
pid: '',
uid: '',
sid: '',
platform: 6001,
gameId: 1009,
openId: ''
};
methods = {
buy() {
console.log('buy click')
this.$apply();
},
cancelBuy() {
console.log('user cancel')
},
};
async onLoad(params) {
// gname=武极天下&pname=首充6元礼包&price=600&sname=双线10服&uname=azwe&oid=1231231313&aid=123123
// 游戏名称
// this.gameName = decodeURIComponent(params.gname);
// wepy.setNavigationBarTitle({
// title: this.gameName
// })
// 订单id
// this.orderId = decodeURIComponent(params.oid);
// 产品编号
this.pid = params.pid;
this.uid = decodeURIComponent(params.uid);
// 服务器id
this.sid = params.sid;
if (!this.pid) {
wepy.reLaunch({
url: '/pages/index'
})
return
}
// 以下都为了显示
// 产品名称
this.productName = decodeURIComponent(params.pname);
// 价格
this.price = decodeURIComponent(params.price);
this.money = `${(this.price / 100).toFixed(2)}`;
// 服务器名称
this.svrName = decodeURIComponent(params.sname);
// 角色名
this.uname = decodeURIComponent(params.uname);
this.openId = decodeURIComponent(params.openid);
params.gameid && (this.gameId = params.gameid);
params.platform && (this.platform = params.platform);
// 以上都是为了显示
this.$apply();
if (sdkManage.session_id) {
this.prePay();
} else {
jcEvent.on(jcEvent.events.LOGIN_FINISHED, this, data => {
this.prePay();
})
}
}
onShow(){
}
async prePay() {
wepy.showLoading({
title: '支付中'
});
let url = g.wjtxPayUrl
let account = wepy.getStorageSync('account');
const payData = {
uid: this.uid,
produce: this.pid,
server: this.sid,
unified_openid: account.openid,
unified_channel: 9002,
platform: this.platform,
gameid: this.gameId,
openid: this.openId
}
url = this.appendMoreParam(url, payData)
sdkManage.gamelog.logButtonClick('pay', {data: payData}, 'payBegin');
try {
let res = await http.get(url);
wepy.hideLoading();
if (res.errcode === 0) {
try {
let orderData = JSON.parse(res.prepayId);
console.log(orderData)
this.beginPay(orderData);
} catch (err) {
sdkManage.gamelog.logButtonClick('pay', {data: payData, errMsg: 'requestPayment:fail prepay'}, 'parError');
wepy.hideLoading();
this.backToApp('requestPayment:fail prepay');
}
}
this.$apply();
} catch (err) {
sdkManage.gamelog.logButtonClick('pay', {data: payData, errMsg: 'requestPayment:fail prepay'}, 'parError');
wepy.hideLoading();
this.backToApp('requestPayment:fail prepay');
}
}
appendMoreParam(url, data) {
let paramStr = "";
if (data) {
if (typeof data === 'string') {
paramStr = data;
} else {
for (let key in data) {
if (paramStr !== "") {
paramStr += "&";
}
paramStr += key + "=" + encodeURIComponent(data[key]);
}
}
if (paramStr !== "") {
paramStr = (url.indexOf("?") === -1 ? "?" : "&") + paramStr;
}
}
return url + paramStr;
}
beginPay(payInfo) {
let self = this;
if (payInfo.timeStamp) {
payInfo.timeStamp = payInfo.timeStamp + ''
}
if (!payInfo.signType) {
payInfo.signType = 'RSA'
}
payInfo.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);
}
wx.requestPayment(payInfo)
}
backToApp(errMsg) {
wepy.navigateBackMiniProgram({
extraData: {
payData: errMsg,
orderid: this.orderId,
type: 'payresult'
},
complete: (res) => {
console.log('navigateBackMiniProgram success, now to index');
}
})
}
}
</script>
<style lang="less">
.weui-form-preview {
position: relative;
background-color: #FFFFFF;
margin-bottom: 25px;
width: 100%;
}
.weui-form-preview:before {
content: " ";
position: absolute;
left: 0;
top: 0;
right: 0;
height: 1px;
border-top: 1rpx solid #D9D9D9;
color: #D9D9D9;
border-top-width: 1px;
border-top-style: solid;
border-top-color: rgb(217, 217, 217);
}
.weui-form-preview__hd:after {
content: " ";
position: absolute;
left: 0;
bottom: 0;
right: 0;
height: 1px;
border-bottom: 1rpx solid #D9D9D9;
color: #D9D9D9;
left: 15px;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: rgb(217, 217, 217);
}
.weui-form-preview__hd {
position: relative;
padding: 10px 15px;
text-align: right;
line-height: 2.5em;
}
.weui-form-preview__item {
overflow: hidden;
display: block;
}
.weui-form-preview__label {
float: left;
margin-right: 1em;
min-width: 4em;
color: #999999;
text-align: justify;
text-align-last: justify;
}
.weui-form-preview__bd {
padding: 10px 15px;
font-size: 0.9em;
text-align: right;
color: #999999;
line-height: 2;
}
.weui-form-preview__value {
display: block;
overflow: hidden;
word-break: normal;
word-wrap: break-word;
}
.weui-form-preview__value_in-hd {
font-size: 26px;
color: #E64340;
}
.weui-form-preview__ft {
position: relative;
line-height: 50px;
padding: 20px 15px 10px;
}
.weui-form-preview__ft:after {
content: " ";
position: absolute;
left: 0;
top: 0;
right: 0;
height: 1px;
border-top: 1rpx solid #D5D5D6;
color: #D5D5D6;
border-top-width: 1px;
border-top-style: solid;
border-top-color: rgb(213, 213, 214);
}
</style>

View File

@ -80,14 +80,14 @@
}
};
async onLoad(params) {
onLoad(params) {
jcEvent.on(jcEvent.events.NEED_UPDATE_CFG, this, data => {
this.loadCfg();
this.$apply();
})
this.loadCfg();
this.gid = decodeURIComponent(params.gid);
await this.getUserInfo();
this.getUserInfo();
}
onShow(){

View File

@ -1,25 +0,0 @@
{
"rules":[{
"action": "allow",
"page": "pages/index"
}, {
"action": "allow",
"page": "pages/detail"
}, {
"action": "disallow",
"page": "pages/product"
}, {
"action": "disallow",
"page": "pages/buyvip"
}, {
"action": "disallow",
"page": "pages/normal"
}, {
"action": "disallow",
"page": "pages/exchange-result"
}, {
"action": "disallow",
"page": "pages/exchange-record"
}
]
}

View File

@ -15,7 +15,7 @@ const post = (url, data, header) => {
}
const Ajax = (url, method, data, header) => {
url = url.startsWith('http') ? url : g.apiBase + url;
url = g.apiBase + url
header = header || {}
return new Promise((resolve, reject) => {