微商城用户模块总结

原创 2019-01-18 10:51:23 283
摘要:首先有一个问题没有得到解决.goPay : function(){ wx.requestPayment({ timeStamp: '', nonceStr: '', package: '', signType: '', paySign: '', })

首先有一个问题没有得到解决.

goPay : function(){
wx.requestPayment({
timeStamp: '',
nonceStr: '',
package: '',
signType: '',
paySign: '',
})
}

实在是没找到出现了什么状况,微信支付就是不出现.请老师帮忙解决一下.工单里有提问

------------------------------------------------------------------------------

下面是用户模块总结

1.用户登陆模块

    * 通过wx.login({})来实现登陆,

    * bindgetuserinfo来获取用户信息

<button open-type="getUserInfo" bindgetuserinfo="getUserInfo"  wx:if="{{userKey == false}}">授权登录</button>
function login(url, data, fun, that) {
if (url == 'undefined') {
return false;
}
wx.login({
success(res) {
wx.request({
url: 'https://api.weixin.qq.com/sns/jscode2session',
data: {
appid: AppID,
secret: AppSecret,
js_code: res.code,
grant_type: 'authorization_code'
},
method: "POST",
dataType: "json",
header: {
'content-type': 'application/json' // 默认值
},
success: function (res) {
    console.log(res);
    data.unionid = 1;
    post(url, data, fun, that);
    },
    fail: function (res) {
    console.log('获取用户信息失败!');
    return {};
    }
    })
    }
    });
}

    2.wx.showToast({}) 弹出提示框

wx.showToast({
    title: '请先登录',    //提示语
    icon:'none',    //图标
    duration : 1500    //几秒后消失
})

    3.wx.navigateBack({})     返回第几级

var goIndex = setTimeout(function(){
    wx.navigateBack({
        delta: 2
    })
},1500)    //1.5s后返回第二级

    4.wx.requestPayment({})    微信支付  我的痛啊....怎么就是不弹窗

wx.requestPayment({
    timeStamp: '',  //时间戳
    nonceStr: '',   //随机字符串
    package: '',    //统一下单接口返回的 prepay_id 参数值
    signType: '', //签名算法 不是必须
    paySign: '',  //签名
})

    5.wx.showModal({})    确认框

wx.showModal({
    title: '取消订单',    //标题
    content: '确定取消订单?,取消将删除此订单',    //内容
    success(res) {    //成功回调
        if (res.confirm) {
            console.log('用户点击确定')
            com.post('/api/home/cancel_order', { id: pid }, "getRes", that);
        } else if (res.cancel) {
            console.log('用户点击取消')
        }
    }
})

    5.wx.chooseAddress({})    原生获取地址

    6.<checkbox-group bindchange="checkboxChange">  多选点击修改时触发事件

    7.当调用this时层级发生变化时,如在函数内使用wx.xxxx的回调函数中, 先声明一个标量来存储this  如下

cancelOrder : function(e){
    console.log(e)
    var that = this
    var pid = e.currentTarget.dataset.id
    wx.showModal({
        title: '取消订单',
        content: '确定取消订单?,取消将删除此订单',
        success(res) {
            if (res.confirm) {
                console.log('用户点击确定')
                com.post('/api/home/cancel_order', { id: pid }, "getRes", that);
            } else if (res.cancel) {
                console.log('用户点击取消')
            }
        }
    })
}


1.png2.png3.png4.png5.png6.png7.png


    新知识大概就这些了,小程序整体上来说还算好懂,看来我还需要多看看文档了,还有请老师帮忙解决一下这个微信支付不弹窗的问题

批改老师:查无此人批改时间:2019-01-18 11:53:00
老师总结:工单我好像回过你了,没看到?示例也给你了。作业完成的不错,说明你用心了。继续加油。

发布手记

热门词条