|
|
@@ -11,16 +11,25 @@
|
|
|
</template>
|
|
|
<script>
|
|
|
import { getWeixinId } from "@/api/invite/index"
|
|
|
+import { getCgSalt } from "@/api/order"
|
|
|
export default {
|
|
|
name: "showCgOrder",
|
|
|
data() {
|
|
|
return {
|
|
|
getAppIdList:{},
|
|
|
showButton:false,
|
|
|
- id:0
|
|
|
+ id:0,
|
|
|
+ purchaseId:0,
|
|
|
+ cgSalt:'',
|
|
|
+ saltRequestId:0,
|
|
|
+ saltPromise:null,
|
|
|
+ loadedOptionId:0,
|
|
|
+ ignoreNextShowId:0
|
|
|
};
|
|
|
},
|
|
|
- onLoad() {
|
|
|
+ onLoad(option) {
|
|
|
+ this.setOptionInfo(option || this.option || {}, true)
|
|
|
+ this.ignoreNextShowId = this.id
|
|
|
let that = this
|
|
|
getWeixinId().then(res => {
|
|
|
that.getAppIdList = res.data
|
|
|
@@ -28,27 +37,76 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
onShow() {
|
|
|
- if(this.option.id){
|
|
|
- this.id = this.option.id
|
|
|
+ const option = this.option || {}
|
|
|
+ const id = option.id || 0
|
|
|
+ if(id && this.ignoreNextShowId == id){
|
|
|
+ this.ignoreNextShowId = 0
|
|
|
+ this.setOptionInfo(option)
|
|
|
+ return false
|
|
|
}
|
|
|
+ this.setOptionInfo(option, true)
|
|
|
},
|
|
|
methods: {
|
|
|
init(){
|
|
|
- if(this.option.id){
|
|
|
- this.id = this.option.id
|
|
|
+ this.setOptionInfo(this.option || {}, true)
|
|
|
+ },
|
|
|
+ setOptionInfo(option, refreshSalt = false){
|
|
|
+ const id = option.id || 0
|
|
|
+ if(!id){
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if(this.id != id){
|
|
|
+ this.cgSalt = ''
|
|
|
+ this.purchaseId = 0
|
|
|
+ this.saltRequestId = 0
|
|
|
+ this.saltPromise = null
|
|
|
+ }
|
|
|
+ this.id = id
|
|
|
+ if(refreshSalt || this.loadedOptionId != id){
|
|
|
+ this.loadedOptionId = id
|
|
|
+ this.getCgSaltInfo()
|
|
|
}
|
|
|
},
|
|
|
- showCgOrder() {
|
|
|
+ getCgSaltInfo(){
|
|
|
+ if(!this.id){
|
|
|
+ return Promise.resolve(false)
|
|
|
+ }
|
|
|
+ if(this.saltPromise && this.saltRequestId == this.id){
|
|
|
+ return this.saltPromise
|
|
|
+ }
|
|
|
+ this.saltRequestId = this.id
|
|
|
+ this.saltPromise = getCgSalt({id:this.id}).then(res => {
|
|
|
+ this.purchaseId = res.data.purchaseId || 0
|
|
|
+ this.cgSalt = res.data.cgSalt || ''
|
|
|
+ this.saltPromise = null
|
|
|
+ return this.cgSalt
|
|
|
+ }).catch(err => {
|
|
|
+ this.saltPromise = null
|
|
|
+ throw err
|
|
|
+ })
|
|
|
+ return this.saltPromise
|
|
|
+ },
|
|
|
+ async showCgOrder() {
|
|
|
let that = this
|
|
|
- console.log('pagesPurchase/purDetails?id='+that.option.id)
|
|
|
+ if(!that.cgSalt){
|
|
|
+ await that.getCgSaltInfo()
|
|
|
+ }
|
|
|
+ const salt = that.cgSalt || ''
|
|
|
+ const purchaseId = that.purchaseId || 0
|
|
|
+ if(!purchaseId || !salt){
|
|
|
+ that.$msg('订单信息获取失败')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ console.log('pagesPurchase/purDetails?id='+purchaseId+'&salt='+salt)
|
|
|
uni.navigateToMiniProgram({
|
|
|
//姜枫-2021.04.13
|
|
|
appId: that.getAppIdList.hd.miniAppId,
|
|
|
- path: 'pagesPurchase/purDetails?id='+that.option.id,
|
|
|
+ path: 'pagesPurchase/purDetails?id='+purchaseId+'&salt='+salt,
|
|
|
//develop 开发版 trial 体验版 release 正式版
|
|
|
envVersion: process.env.NODE_ENV === 'development' ? 'develop' : 'release',
|
|
|
extraData: {
|
|
|
- 'id': that.option.id
|
|
|
+ 'id': purchaseId,
|
|
|
+ 'salt': salt
|
|
|
},
|
|
|
success (res) {
|
|
|
}
|
|
|
@@ -101,4 +159,4 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|