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}) return request.post("order/confirm", {id})
} }
// 支付结果 // 支付结果
export function getPayResult(params) { export function getPayResult(params) {
return request.get("order/pay_result", { 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> </image>
<text class="xxs lighter">收藏</text> <text class="xxs lighter">收藏</text>
</button> </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"> <view class="flex-col btn cart col-center row-center">
<image class="icon-md" src="/static/images/icon_cart.png"></image> <image class="icon-md" src="/static/images/icon_cart.png"></image>
<text class="xxs lighter">购物车</text> <text class="xxs lighter">购物车</text>
<u-badge v-if="cartNum" :bgColor="colorConfig.primary" :offset="[8, 10]" :count="cartNum"> <u-badge v-if="cartNum" :bgColor="colorConfig.primary" :offset="[8, 10]" :count="cartNum">
</u-badge> </u-badge>
</view> </view>
</router-link> </router-link> -->
<template v-if="shop.is_pay"> <template v-if="shop.is_pay">
<!-- goodsDetail.type == 0 是虚拟商品时购物车不显示 --> <!-- 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)"> <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="line m-t-40"></view>
<view class="m-t-40 flex-col row-center"> <view class="m-t-40 flex-col row-center">
<router-link :to="getPagesUrl" navType="replace"> <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>
<router-link navType="pushTab" to="/pages/index/index"> <router-link navType="pushTab" to="/pages/index/index">
<button size="lg" class="br60 plain primary m-t-30">返回首页</button> <button size="lg" class="br60 plain primary m-t-30">返回首页</button>
@ -52,7 +52,8 @@
data() { data() {
return { return {
payInfo: {}, payInfo: {},
from: '' from: '',
showBtn:"返回首页",
}; };
}, },
@ -61,7 +62,10 @@
console.log(options) console.log(options)
this.id = options.id this.id = options.id
this.from = options.from this.from = options.from
this.type = options.type
this.org_id = options.org_id
this.getOrderResultFun(); this.getOrderResultFun();
}, },
@ -79,6 +83,17 @@
}, },
computed: { computed: {
getPagesUrl() { 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) { switch(this.from) {
case 'integral': return '/bundle/pages/exchange_order/exchange_order' case 'integral': return '/bundle/pages/exchange_order/exchange_order'
default: return '/bundle/pages/user_order/user_order' default: return '/bundle/pages/user_order/user_order'

201
pages/resource_details/resource_details.vue

@ -66,8 +66,8 @@
<goods-column></goods-column> <goods-column></goods-column>
</view> </view>
<share-popup :show="showShareBtn" @close="showShareBtn = false" :goods-id="id" :img-url="goodsDetail.image" <share-popup :show="showShareBtn" @close="showShareBtn = false" :goods-id="id" :img-url="resourceDetail.image"
:summary="goodsDetail.remark" :share-title="goodsDetail.name"></share-popup> :summary="resourceDetail.intro" :share-title="resourceDetail.title"></share-popup>
<!-- 悬浮按钮 --> <!-- 悬浮按钮 -->
<float-tab></float-tab> <float-tab></float-tab>
@ -77,6 +77,14 @@
team_min_price team_min_price
<script> <script>
import { import {
resourceOrderBuy
} from '@/api/order';
import {
prepay,
getMnpNotice,
getPayway
} from '@/api/app';
import {
getResourceDetail, getResourceDetail,
getGoodsDetail, getGoodsDetail,
addCart addCart
@ -191,20 +199,74 @@ team_min_price
// //
if(goodsType == 0){ if(goodsType == 0){
let msg = "下载中...";
this.showLoading = false
uni.showLoading({
title: msg
});
console.log(this)
uni.downloadFile({ uni.downloadFile({
url: this.goodsDetail.path, // url: this.resourceDetail.path, //
success: (res) => { success: (res) => {
if (res.statusCode === 200) { 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 }else if(goodsType == 1){ //vip
uni.navigateTo({ uni.navigateTo({
url: '/pages/user/vip' url: '/pages/user/vip'
}); });
}else if(goodsType == 2){ // }else if(goodsType == 2){ //
console.log('购买页') console.log('购买页')
this.onSubmitOrder();
} }
}, },
changeActive(index) { changeActive(index) {
@ -287,62 +349,99 @@ team_min_price
this.popupType = type; this.popupType = type;
this.showSpec = true; this.showSpec = true;
}, },
onBuy(e) {
if (!this.isLogin) return this.$Router.push('/pages/login/login') getAuthMsg() {
const { return new Promise(resolve => {
id, getMnpNotice({
goodsNum scene: 1
} = e.detail; }).then(res => {
const params = { if (res.code == 1) {
goods: [{ uni.requestSubscribeMessage({
item_id: id, tmplIds: res.data,
num: goodsNum,
goods_id: this.id, fail(res) {
shop_id: this.shop.id, console.log(res.errMsg);
delivery_type: this.goodsDetail.type },
}],
type: 'buy' complete() {
}; resolve();
this.showSpec = false }
this.goodsType == 2 ? (params.teamId = this.team.id) : '';
this.foundId ? (params.foundId = this.foundId) : ''; });
this.$Router.push({ } else {
path: '/pages/confirm_order/confirm_order', resolve();
query: { }
data: params });
} });
})
}, },
onConfirm(e) { onSubmitOrder() {
const { uni.showModal({
team: { title: '温馨提示',
team_id content: '是否确认购买?',
} confirmColor: '#FF2C3C',
} = this; confirmText:"前往支付",
success: async res => {
teamCheck({ let {
team_id: this.foundId, confirm
// found_id: this.foundId, } = res;
goods_id: e.detail.goods_id, if (confirm) {
item_id: e.detail.id, // #ifdef MP-WEIXIN
count: e.detail.goodsNum await this.getAuthMsg();
}).then(res => { //#endif
if (res.code == 1) { this.showLoading = true
this.onBuy(e); 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() { async onShareAppMessage() {
const { const {
goodsDetail, resourceDetail,
inviteCode, inviteCode,
team team
} = this; } = this;
return { return {
title: team.share_title || goodsDetail.name, title: resourceDetail.title,
imageUrl: goodsDetail.image, imageUrl: resourceDetail.image,
path: '/pages/goods_details/goods_details?id=' + this.id + "&invite_code=" + inviteCode path: '/pages/resource_details/resource_details?id=' + this.id
}; };
}, },
computed: { computed: {

13
pages/resource_list/resource_list.vue

@ -135,9 +135,9 @@
async getCategoryListFun() { async getCategoryListFun() {
let { let {
cityInfo cityInfo,
isLogin
} = this; } = this;
const { const {
code, code,
data data
@ -151,9 +151,14 @@
if(cityInfo.id !=null && cityInfo.id!=undefined && cityInfo.id>0){ if(cityInfo.id !=null && cityInfo.id!=undefined && cityInfo.id>0){
item = {id:"city_"+cityInfo.id,name:"本地"} item = {id:"city_"+cityInfo.id,name:"本地"}
} }
console.log(this.categoryList,12222)
this.categoryList.push(item) 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: { computed: {

114
pages/user/vip.vue

@ -65,6 +65,14 @@
<script> <script>
import MescrollCompMixin from "@/components/mescroll-uni/mixins/mescroll-comp"; import MescrollCompMixin from "@/components/mescroll-uni/mixins/mescroll-comp";
import { import {
userOrderBuy,
userFreeOrderBuy
} from '@/api/order';
import {
getMnpNotice
} from '@/api/app';
import {
mapGetters, mapGetters,
mapActions mapActions
} from 'vuex' } from 'vuex'
@ -133,6 +141,7 @@
memberEndTime: '', memberEndTime: '',
type: '', type: '',
org_id:0,
svip: null, svip: null,
mc_id: 0, mc_id: 0,
initIn: false initIn: false
@ -206,8 +215,10 @@
pay() { pay() {
if (this.type === 'free') { if (this.type === 'free') {
console.log("开启试用") console.log("开启试用")
this.orderFreeBuyFun();
} else { } else {
console.log("开启支付") console.log("开启购买")
this.onSubmitOrder();
} }
}, },
scrollToCard() { scrollToCard() {
@ -223,6 +234,7 @@
this.svip = svip; this.svip = svip;
this.totalPrice = svip.pre_price this.totalPrice = svip.pre_price
this.mc_id = svip.id this.mc_id = svip.id
this.org_id = svip.id
getUserVipTime({ getUserVipTime({
id: svip.id, id: svip.id,
}).then(res => { }).then(res => {
@ -270,6 +282,106 @@
tempform.submit(); 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