Commit 05984c50 by 汪睦雄

123

parent bf04ed01
...@@ -40,23 +40,16 @@ Component({ ...@@ -40,23 +40,16 @@ Component({
*/ */
methods: { methods: {
_tapBanner(event) { _tapBanner(event) {
let oid = event.currentTarget.dataset.oid
let type = event.currentTarget.dataset.type let type = event.currentTarget.dataset.type
let url = event.currentTarget.dataset.url let url = event.currentTarget.dataset.url
let type_text = event.currentTarget.dataset.txt let type_text = '网页详情'
if (type == 1) { if (type == 1 && Util.isString(url)) {
// 小程序页面
wx.navigateTo({ wx.navigateTo({
url: '/pages/course/single/index?id=' + oid, url: url,
}) })
} else if (type == 2) { } else if (type == 2 && Util.isString(url)) {
wx.navigateTo({ // 网页链接
url: '/pages/course/multiple/index?id=' + oid,
})
} else if (type == 3) {
wx.navigateTo({
url: '/pages/courses/coach/index?id=' + oid,
})
} else if (type == 4 && Util.isString(url)) {
wx.navigateTo({ wx.navigateTo({
url: '/pages/webview/index?url=' + url + '&t=' + type_text, url: '/pages/webview/index?url=' + url + '&t=' + type_text,
}) })
......
...@@ -12,61 +12,61 @@ Page({ ...@@ -12,61 +12,61 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function(options) {
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function () { onReady: function() {
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function() {
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function() {
}, },
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function () { onUnload: function() {
}, },
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function () { onPullDownRefresh: function() {
}, },
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onReachBottom: function() {
}, },
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage: function () { onShareAppMessage: function() {
}, },
// 分类点击 // 分类点击
catalogClick: function (event) { catalogClick: function(event) {
let _catalog = event.currentTarget.dataset.catalog let _catalog = event.currentTarget.dataset.catalog
let _ptitle = event.currentTarget.dataset.name let _ptitle = event.currentTarget.dataset.name
wx.navigateTo({ wx.navigateTo({
...@@ -75,16 +75,16 @@ Page({ ...@@ -75,16 +75,16 @@ Page({
}, },
// 美行攻略 // 美行攻略
gotoGuides: function (event) { gotoGuides: function(event) {
wx.navigateTo({ wx.navigateTo({
url: '/pages/guide/index', url: '/pages/guide/index',
}) })
}, },
// 商家合作 // 商家合作
gotoShopJoin: function (event) { gotoShopJoin: function(event) {
wx.navigateTo({ wx.navigateTo({
url: '/pages/webview/index?url=' + Config.shopJoinPath, url: '/pages/webview/index?url=' + Config.shopJoinPath + '&t=商家合作',
}) })
} }
......
...@@ -23,7 +23,9 @@ Page({ ...@@ -23,7 +23,9 @@ Page({
adultNum: 0, adultNum: 0,
childrenNum: 0, childrenNum: 0,
childrenAge: 0, childrenAge: 0,
remark: '' remark: '',
// 订单
order: {}
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
...@@ -144,6 +146,7 @@ Page({ ...@@ -144,6 +146,7 @@ Page({
}, },
handleSubmit: function() { handleSubmit: function() {
let that = this
if (!this.data.familyNum || !this.data.nickname || !this.data.phone) { if (!this.data.familyNum || !this.data.nickname || !this.data.phone) {
$Toast({ $Toast({
content: '请完善必要信息', content: '请完善必要信息',
...@@ -173,8 +176,55 @@ Page({ ...@@ -173,8 +176,55 @@ Page({
content: res.msg, content: res.msg,
type: 'error' type: 'error'
}); });
} else {
console.log("获取支付参数", res)
that.setData({
order: res.data
})
// 发起微信支付
wx.requestPayment({
timeStamp: '' + res.result.timeStamp,
nonceStr: '' + res.result.nonceStr,
package: '' + res.result.package,
signType: '' + res.result.signType,
paySign: '' + res.result.paySign,
success: function(ret) {
console.log(ret)
if (ret.errMsg === 'requestPayment:ok') {
that.setOrderPaid(that.data.order.order_id, function(res) {
// 支付同步回调结果
console.log("发送模版消息", res)
// 跳转到订单页面
wx.showToast({
title: '支付成功',
})
setTimeout(() => {
wx.navigateTo({
url: '/pages/me/order/index?order=1',
})
}, 800)
})
} else {
wx.showToast({
title: ret.errMsg,
})
}
} }
console.log(res)
}) })
} }
})
},
/**
* 同步支付结果回调:发送模版消息
*/
setOrderPaid(id, callback) {
let params = {
order_id: id
}
api.me.vipOrderSendTemplate(params).then(res => {
typeof callback == "function" && callback(res)
})
}
}) })
\ No newline at end of file
...@@ -109,6 +109,7 @@ Page({ ...@@ -109,6 +109,7 @@ Page({
url: '/pages/prjlist/list?type=' + _type + '&ptitle=' + _ptitle, url: '/pages/prjlist/list?type=' + _type + '&ptitle=' + _ptitle,
}) })
}, },
// 更多:按分类筛选 // 更多:按分类筛选
gotoSearchProjects: function(event) { gotoSearchProjects: function(event) {
let _catalog = event.target.dataset.catalog let _catalog = event.target.dataset.catalog
...@@ -118,6 +119,7 @@ Page({ ...@@ -118,6 +119,7 @@ Page({
}) })
}, },
// 跳转详情页
handleProjectDetail: function(event) { handleProjectDetail: function(event) {
const id = event.currentTarget.dataset.id const id = event.currentTarget.dataset.id
wx.navigateTo({ wx.navigateTo({
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<i-cell-group i-class='vip'> <i-cell-group i-class='vip'>
<i-cell title="VIP会员" is-link url="/pages/me/vip/index?is_vip={{user.is_vip}}&vip_endtime={{user.vip_endtime}}"> <i-cell title="VIP会员" is-link url="/pages/me/vip/index?is_vip={{user.is_vip}}&vip_endtime={{user.vip_endtime}}">
<text slot="footer" class='text-gray'>{{user.vip_endtime==null?'':user.vip_endtime}}</text> <text slot="footer" class='text-gray'>{{user.vip_endtime==null?'':user.vip_endtime_str}}</text>
</i-cell> </i-cell>
<i-cell title="我的收藏" is-link url="/pages/me/collection/index"></i-cell> <i-cell title="我的收藏" is-link url="/pages/me/collection/index"></i-cell>
</i-cell-group> </i-cell-group>
......
...@@ -10,20 +10,23 @@ Page({ ...@@ -10,20 +10,23 @@ Page({
value1: 1, value1: 1,
value2: 0.1, value2: 0.1,
is_vip: 0,
vip_endtime: null,
vip_price: 49.9, vip_price: 49.9,
order: {} order: {},
user: {}
}, },
handleChange1({ detail }) { handleChange1({
detail
}) {
this.setData({ this.setData({
value1: detail.value value1: detail.value
}) })
}, },
handleChange2({ detail }) { handleChange2({
detail
}) {
this.setData({ this.setData({
value2: detail.value value2: detail.value
}) })
...@@ -32,24 +35,32 @@ Page({ ...@@ -32,24 +35,32 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function(options) {
let userInfo = app.globalData.userInfo this.getUserInfo()
let is_vip = userInfo.is_vip this.getVipPrice()
let vip_endtime = userInfo.vip_endtime },
// 获取个人资料
getUserInfo: function() {
api.me.info().then(res => {
if (!res.code) {
app.globalData.userInfo = res.data
// 渲染数据
this.setData({ this.setData({
is_vip: is_vip, user: res.data
vip_endtime: vip_endtime })
}
}) })
}, },
// 获取VIP单价 // 获取VIP单价
getVipPrice: function () { getVipPrice: function() {
api.me.vipPrice().then(res => { api.me.vipPrice().then(res => {
if (!res.code) { if (!res.code) {
this.setData({ this.setData({
vip_price: res.price vip_price: res.price
}) })
}else{ } else {
wx.showToast({ wx.showToast({
title: res.msg title: res.msg
}) })
...@@ -60,56 +71,56 @@ Page({ ...@@ -60,56 +71,56 @@ Page({
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function () { onReady: function() {
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function() {
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function() {
}, },
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function () { onUnload: function() {
}, },
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function () { onPullDownRefresh: function() {
}, },
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onReachBottom: function() {
}, },
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage: function () { onShareAppMessage: function() {
}, },
/** /**
* 立即购买/续费 * 立即购买/续费
*/ */
handleClick: function (){ handleClick: function() {
let that = this let that = this
let year = this.data.value1 let year = this.data.value1
let params = { let params = {
...@@ -118,7 +129,6 @@ Page({ ...@@ -118,7 +129,6 @@ Page({
// 获取支付参数 // 获取支付参数
api.me.vipOrder(params).then(res => { api.me.vipOrder(params).then(res => {
if (res.code == 0) { if (res.code == 0) {
console.log("获取支付参数", res)
that.setData({ that.setData({
order: res.data order: res.data
}) })
...@@ -129,30 +139,41 @@ Page({ ...@@ -129,30 +139,41 @@ Page({
package: '' + res.result.package, package: '' + res.result.package,
signType: '' + res.result.signType, signType: '' + res.result.signType,
paySign: '' + res.result.paySign, paySign: '' + res.result.paySign,
success: function (ret) { success: function(ret) {
that.setOrderPaid(that.data.order.order_id, function (res) { console.log(ret)
if (ret.errMsg === 'requestPayment:ok') {
that.setOrderPaid(that.data.order.order_id, function(res) {
// 支付同步回调结果 // 支付同步回调结果
console.log(res) console.log("发送模版消息", res)
// 刷新当前页面
setTimeout(() => {
that.getUserInfo()
}, 500)
}) })
} else {
wx.showToast({
title: ret.errMsg,
})
}
} }
}) })
}else{ } else {
wx.showToast({ wx.showToast({
title: res.msg, title: res.msg,
}) })
} }
}) })
}, },
/** /**
* 同步支付结果回调:重置订单状态 * 同步支付结果回调:重置订单状态
*/ */
setOrderPaid(id, callback) { setOrderPaid(id, callback) {
let that = this
let params = { let params = {
order_id: id order_id: id
} }
api.me.vipOrderPaied(params).then(res => { api.me.vipOrderSendTemplate(params).then(res => {
typeof callback == "function" && callback() typeof callback == "function" && callback(res)
}) })
} }
}) })
\ No newline at end of file
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
<wxs src="../../../pages/common.wxs" module="common"></wxs> <wxs src="../../../pages/common.wxs" module="common"></wxs>
<view class='card-box'> <view class='card-box'>
<image src="/images/background-{{is_vip==1?'':'no'}}vip.png"></image> <image src="/images/background-{{user.is_vip==1?'':'no'}}vip.png"></image>
<text> {{is_vip==1?vip_endtime:''}}</text> <text> {{user.is_vip==1?user.vip_endtime:''}}</text>
</view> </view>
<view class='calculation-box'> <view class='calculation-box'>
<i-row class='height'> <i-row class='height'>
<i-col span="6" offset='1' i-class="col-class">{{is_vip==1?'续费':'购买'}}会员</i-col> <i-col span="6" offset='1' i-class="col-class">{{user.is_vip==1?'续费':'购买'}}会员</i-col>
<i-col span="4" i-class="col-class color-orange">¥ {{vip_price}}</i-col> <i-col span="4" i-class="col-class color-orange">¥ {{vip_price}}</i-col>
<i-col span="12" offset='1' i-class="col-class"> <i-col span="12" offset='1' i-class="col-class">
<i-input-number i-class="vip_num_input" value="{{ value1 }}" min="1" max="10" bindchange="handleChange1" /> <i-input-number i-class="vip_num_input" value="{{ value1 }}" min="1" max="10" bindchange="handleChange1" />
...@@ -22,6 +22,6 @@ ...@@ -22,6 +22,6 @@
<i-row class='height'> <i-row class='height'>
<i-col span="20" offset='2' i-class="col-class"> <i-col span="20" offset='2' i-class="col-class">
<i-button bind:click="handleClick" type="primary" shape="circle" size="small">立即{{is_vip==1?'续费':'购买'}} ¥{{common.numFixed(vip_price*value1, 2)}}</i-button> <i-button bind:click="handleClick" type="primary" shape="circle" size="small">立即{{user.is_vip==1?'续费':'购买'}} ¥{{common.numFixed(vip_price*value1, 2)}}</i-button>
</i-col> </i-col>
</i-row> </i-row>
\ No newline at end of file
...@@ -61,8 +61,8 @@ export const me = { ...@@ -61,8 +61,8 @@ export const me = {
vipOrder: params => { vipOrder: params => {
return req.post('order/vipOrder', params).then(res => res.data) return req.post('order/vipOrder', params).then(res => res.data)
}, },
vipOrderPaied: params => { vipOrderSendTemplate: params => {
return req.post('order/vipOrderPaied', params).then(res => res.data) return req.post('order/sendTemplate', params).then(res => res.data)
}, },
uploadAvatar: (name, filePath, params) => { uploadAvatar: (name, filePath, params) => {
return req.upload('User/uploadAvatar', name, filePath, params).then(res => res.data) return req.upload('User/uploadAvatar', name, filePath, params).then(res => res.data)
......
...@@ -15,6 +15,7 @@ class Request { ...@@ -15,6 +15,7 @@ class Request {
interceptors = [] interceptors = []
// 构造方法
constructor() { constructor() {
const token = wx.getStorageSync('token') const token = wx.getStorageSync('token')
if (token) { if (token) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment