You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
// pages/home/me/member/member.js
import Toast from 'tdesign-miniprogram/toast/index' ;
const app = getApp ( ) ; //新建页面时 默认引入
const req = app . xzjlReq ( ) ; //初始化一个的request() 实例
Page ( {
/**
* 页面的初始数据
*/
data : {
yhy : true ,
openid : '' ,
showToast : false
} ,
doKtHy ( ) {
req . postRequest ( ` /api/v1/chat-service-order/prepare/ ${ this . data . yhy ? '2' : '1' } ` , {
openid : this . data . openid
} ) . then ( ( res ) => {
console . log ( res ) ;
// 调用微信支付方法
wx . requestPayment ( {
//成功之后,调用小程序微信支付
timeStamp : res . data . data . timeStamp ,
nonceStr : res . data . data . nonceStr ,
package : res . data . data . packageVal ,
signType : 'MD5' ,
paySign : res . data . data . paySign ,
success : res => {
//支付成功的回调这里面写支付成功后跳转的路径
wx . showToast ( {
title : '支付成功' , // 标题
icon : 'success' , // 图标类型, 默认success 图标支持开发文档的icon
} )
setTimeout ( ( ) => {
wx . switchTab ( {
url : '/pages/home/me/indexx' ,
} )
} , 1000 )
} ,
fail : ( ) => {
// uni.showToast({
// icon: 'none',
// title: '支付失败'
// });
}
} ) ;
} )
/**开通会员操作 */
console . log ( '开通会员' )
} ,
go2Week ( ) {
this . setData ( { yhy : false } )
} ,
go2Month ( ) {
this . setData ( { yhy : true } )
} ,
go2Reback ( ) {
wx . navigateBack ( { changed : true } ) ;
} ,
tQuest ( ) {
this . setData ( { showToast : true } )
} ,
closeTaost ( ) {
this . setData ( { showToast : false } )
console . log ( '点击了' ) ;
} ,
/**
* 生命周期函数--监听页面加载
*/
onLoad ( options ) {
wx . login ( {
provider : 'weixin' ,
success : loginRes => {
//loginRes中有code, 拿着code再请求自己服务器以获取openid
console . log ( loginRes . code , 888888888888 ) ;
req . getRequest ( ` /api/v1/chat-service-order/js-code2-session ` , {
code : loginRes . code
} ) . then ( ( res ) => {
console . log ( res ) ;
// this.openid = res.data.openid
this . setData ( {
openid : res . data . data . openid
} )
} )
}
} ) ;
} ,
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady ( ) {
} ,
/**
* 生命周期函数--监听页面显示
*/
onShow ( ) {
} ,
/**
* 生命周期函数--监听页面隐藏
*/
onHide ( ) {
} ,
/**
* 生命周期函数--监听页面卸载
*/
onUnload ( ) {
} ,
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh ( ) {
} ,
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom ( ) {
} ,
/**
* 用户点击右上角分享
*/
onShareAppMessage ( ) {
}
} )