Browse Source

初始化

master
jianglong 3 years ago
parent
commit
6d554e2011
  1. 17
      api/order.js
  2. 4
      pages/goods_details/goods_details.vue
  3. 19
      pages/pay_result/pay_result.vue
  4. 201
      pages/resource_details/resource_details.vue
  5. 13
      pages/resource_list/resource_list.vue
  6. 114
      pages/user/vip.vue

17
api/order.js

@ -38,9 +38,22 @@ export function confirmOrder(id) {
return request.post("order/confirm", {id})
}
// 支付结果
export function getPayResult(params) {
return request.get("order/pay_result", { params });
}
// 下单
export function userOrderBuy(data) {
return request.post("order/submitUserOrder", data);
}
// 开通试用会员卡
export function userFreeOrderBuy(data) {
return request.post("order/submitFreeUserOrder", data);
}
// 下单
export function resourceOrderBuy(data) {
return request.post("order/submitResourceOrder", data);
}

4
pages/goods_details/goods_details.vue

@ -216,14 +216,14 @@
</image>
<text class="xxs lighter">收藏</text>
</button>
<router-link nav-type="pushTab" to="/pages/shop_cart/shop_cart">
<!-- <router-link nav-type="pushTab" to="/pages/shop_cart/shop_cart">
<view class="flex-col btn cart col-center row-center">
<image class="icon-md" src="/static/images/icon_cart.png"></image>
<text class="xxs lighter">购物车</text>
<u-badge v-if="cartNum" :bgColor="colorConfig.primary" :offset="[8, 10]" :count="cartNum">
</u-badge>
</view>
</router-link>
</router-link> -->
<template v-if="shop.is_pay">
<!-- goodsDetail.type == 0 是虚拟商品时购物车不显示 -->
<view v-if="btnText.yellow && goodsDetail.type == 0" class="add-cart br60 white m-r-10 md m-l-20" @tap="showSpecFun(1)">

19
pages/pay_result/pay_result.vue

@ -34,7 +34,7 @@
<view class="line m-t-40"></view>
<view class="m-t-40 flex-col row-center">
<router-link :to="getPagesUrl" navType="replace">
<button type="primary" size="lg" class="br60">查看订单</button>
<button type="primary" size="lg" class="br60">{{showBtn}}</button>
</router-link>
<router-link navType="pushTab" to="/pages/index/index">
<button size="lg" class="br60 plain primary m-t-30">返回首页</button>
@ -52,7 +52,8 @@
data() {
return {
payInfo: {},
from: ''
from: '',
showBtn:"返回首页",
};
},
@ -61,7 +62,10 @@
console.log(options)
this.id = options.id
this.from = options.from
this.type = options.type
this.org_id = options.org_id
this.getOrderResultFun();
},
@ -79,6 +83,17 @@
},
computed: {
getPagesUrl() {
if(this.type == 1 ){
this.showBtn = '查看会员'
return '/pages/user/vip'
}
if(this.type == 2 && this.org_id>0){
this.showBtn = '前往下载'
console.log(this.showBtn)
return '/pages/resource_details/resource_details?id='+this.org_id
}
switch(this.from) {
case 'integral': return '/bundle/pages/exchange_order/exchange_order'
default: return '/bundle/pages/user_order/user_order'

201
pages/resource_details/resource_details.vue

@ -66,8 +66,8 @@
<goods-column></goods-column>
</view>
<share-popup :show="showShareBtn" @close="showShareBtn = false" :goods-id="id" :img-url="goodsDetail.image"
:summary="goodsDetail.remark" :share-title="goodsDetail.name"></share-popup>
<share-popup :show="showShareBtn" @close="showShareBtn = false" :goods-id="id" :img-url="resourceDetail.image"
:summary="resourceDetail.intro" :share-title="resourceDetail.title"></share-popup>
<!-- 悬浮按钮 -->
<float-tab></float-tab>
@ -77,6 +77,14 @@
team_min_price
<script>
import {
resourceOrderBuy
} from '@/api/order';
import {
prepay,
getMnpNotice,
getPayway
} from '@/api/app';
import {
getResourceDetail,
getGoodsDetail,
addCart
@ -191,20 +199,74 @@ team_min_price
//
if(goodsType == 0){
let msg = "下载中...";
this.showLoading = false
uni.showLoading({
title: msg
});
console.log(this)
uni.downloadFile({
url: this.goodsDetail.path, //
url: this.resourceDetail.path, //
success: (res) => {
if (res.statusCode === 200) {
console.log('下载成功');
console.log(res);
uni.saveFile({
tempFilePath: res.tempFilePath,
success: function (res2) {
var savedFilePath = res2.savedFilePath;
let msg = "文件存储到"+savedFilePath;
uni.showLoading({
title: msg
});
setTimeout(function () {
uni.hideLoading()
}, 2000);
},
fail: function(err) {
uni.showLoading({
title: "下载失败"
});
setTimeout(function () {
uni.hideLoading()
}, 2000);
}
});
}
}
});
// uni.downloadFile({
// url: this.resourceDetail.path,//
// success(res) {
// //
// uni.saveFile({
// tempFilePath: res.tempFilePath,//
// success: function(res) {
// const savedFilePath = res.savedFilePath;
// //
// uni.openDocument({
// filePath: savedFilePath,
// success: function(res) {
// uni.hideLoading()
// },
// fail: function(res) {},
// complete: function(res) {
// setTimeout(uni.hideLoading(), 4000)
// },
// });
// },
// fail: function(err) { }
// });
// },
// fail(res) {}
// })
}else if(goodsType == 1){ //vip
uni.navigateTo({
url: '/pages/user/vip'
});
}else if(goodsType == 2){ //
console.log('购买页')
this.onSubmitOrder();
}
},
changeActive(index) {
@ -287,62 +349,99 @@ team_min_price
this.popupType = type;
this.showSpec = true;
},
onBuy(e) {
if (!this.isLogin) return this.$Router.push('/pages/login/login')
const {
id,
goodsNum
} = e.detail;
const params = {
goods: [{
item_id: id,
num: goodsNum,
goods_id: this.id,
shop_id: this.shop.id,
delivery_type: this.goodsDetail.type
}],
type: 'buy'
};
this.showSpec = false
this.goodsType == 2 ? (params.teamId = this.team.id) : '';
this.foundId ? (params.foundId = this.foundId) : '';
this.$Router.push({
path: '/pages/confirm_order/confirm_order',
query: {
data: params
}
})
getAuthMsg() {
return new Promise(resolve => {
getMnpNotice({
scene: 1
}).then(res => {
if (res.code == 1) {
uni.requestSubscribeMessage({
tmplIds: res.data,
fail(res) {
console.log(res.errMsg);
},
complete() {
resolve();
}
});
} else {
resolve();
}
});
});
},
onConfirm(e) {
const {
team: {
team_id
}
} = this;
teamCheck({
team_id: this.foundId,
// found_id: this.foundId,
goods_id: e.detail.goods_id,
item_id: e.detail.id,
count: e.detail.goodsNum
}).then(res => {
if (res.code == 1) {
this.onBuy(e);
}
});
onSubmitOrder() {
uni.showModal({
title: '温馨提示',
content: '是否确认购买?',
confirmColor: '#FF2C3C',
confirmText:"前往支付",
success: async res => {
let {
confirm
} = res;
if (confirm) {
// #ifdef MP-WEIXIN
await this.getAuthMsg();
//#endif
this.showLoading = true
this.orderBuyFun('submit');
}
}
});
},
async orderBuyFun() {
const submitObj = {
org_id: this.id //id
};
let {
data: orderData,
code: orderCode,
msg: orderMsg
} = await resourceOrderBuy(submitObj)
if (orderCode !== 1) return this.showLoading = false
this.showLoading = false
let order_id = orderData.trade_id;
uni.$on('payment', params => {
setTimeout(() => {
if (params.result) {
console.log('Jason', this)
this.$Router.replace({
path: '/pages/pay_result/pay_result',
query: {
id: params.order_id,
type:2,
org_id:this.id,
from: "trade"
}
})
} else {
location.reload()
}
}, 1 * 500)
})
uni.navigateTo({
url: `/pages/payment/payment?from=trade&order_id=${order_id}`
})
}
},
async onShareAppMessage() {
const {
goodsDetail,
resourceDetail,
inviteCode,
team
} = this;
return {
title: team.share_title || goodsDetail.name,
imageUrl: goodsDetail.image,
path: '/pages/goods_details/goods_details?id=' + this.id + "&invite_code=" + inviteCode
title: resourceDetail.title,
imageUrl: resourceDetail.image,
path: '/pages/resource_details/resource_details?id=' + this.id
};
},
computed: {

13
pages/resource_list/resource_list.vue

@ -135,9 +135,9 @@
async getCategoryListFun() {
let {
cityInfo
cityInfo,
isLogin
} = this;
const {
code,
data
@ -151,9 +151,14 @@
if(cityInfo.id !=null && cityInfo.id!=undefined && cityInfo.id>0){
item = {id:"city_"+cityInfo.id,name:"本地"}
}
console.log(this.categoryList,12222)
this.categoryList.push(item)
if(isLogin){
item = {id:"my_buy",name:"我的购买"}
this.categoryList.push(item)
item = {id:"my_download",name:"我的下载"}
this.categoryList.push(item)
}
},
},
computed: {

114
pages/user/vip.vue

@ -65,6 +65,14 @@
<script>
import MescrollCompMixin from "@/components/mescroll-uni/mixins/mescroll-comp";
import {
userOrderBuy,
userFreeOrderBuy
} from '@/api/order';
import {
getMnpNotice
} from '@/api/app';
import {
mapGetters,
mapActions
} from 'vuex'
@ -133,6 +141,7 @@
memberEndTime: '',
type: '',
org_id:0,
svip: null,
mc_id: 0,
initIn: false
@ -206,8 +215,10 @@
pay() {
if (this.type === 'free') {
console.log("开启试用")
this.orderFreeBuyFun();
} else {
console.log("开启支付")
console.log("开启购买")
this.onSubmitOrder();
}
},
scrollToCard() {
@ -223,6 +234,7 @@
this.svip = svip;
this.totalPrice = svip.pre_price
this.mc_id = svip.id
this.org_id = svip.id
getUserVipTime({
id: svip.id,
}).then(res => {
@ -270,6 +282,106 @@
tempform.submit();
})
},
getAuthMsg() {
return new Promise(resolve => {
getMnpNotice({
scene: 1
}).then(res => {
if (res.code == 1) {
uni.requestSubscribeMessage({
tmplIds: res.data,
fail(res) {
console.log(res.errMsg);
},
complete() {
resolve();
}
});
} else {
resolve();
}
});
});
},
onSubmitOrder() {
uni.showModal({
title: '温馨提示',
content: '是否确认购买?',
confirmColor: '#FF2C3C',
confirmText:"前往支付",
success: async res => {
let {
confirm
} = res;
if (confirm) {
// #ifdef MP-WEIXIN
await this.getAuthMsg();
//#endif
this.showLoading = true
this.orderBuyFun('submit');
}
}
});
},
async orderFreeBuyFun() {
const submitObj = {
org_id: this.org_id //id
};
let {
data: orderData,
code: orderCode,
msg: orderMsg
} = await userFreeOrderBuy(submitObj)
if (orderCode !== 1) return this.showLoading = false
let msg = "开通会员成功"
this.showLoading = false
setTimeout(function () {
this.showLoading = true
}, 2000);
},
async orderBuyFun() {
const submitObj = {
org_id: this.org_id //id
};
let {
data: orderData,
code: orderCode,
msg: orderMsg
} = await userOrderBuy(submitObj)
if (orderCode !== 1) return this.showLoading = false
this.showLoading = false
let order_id = orderData.trade_id;
uni.$on('payment', params => {
setTimeout(() => {
if (params.result) {
console.log('Jason', this)
this.$Router.replace({
path: '/pages/pay_result/pay_result',
query: {
id: params.order_id,
type:1,
org_id:this.org_id,
from: "trade"
}
})
} else {
location.reload()
}
}, 1 * 500)
})
uni.navigateTo({
url: `/pages/payment/payment?from=trade&order_id=${order_id}`
})
}
},

Loading…
Cancel
Save