l_open.js 1.43 KB
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
Page({
    onLoad:function(opt){
        this.setData({
            username:opt.username,
            sellerid:opt.sellerid
        })
        this.getpayseller();
    },
    onShow:function(){
        var that=this;
        util.postSuccessFun=function(json,uri_code) {
            switch (uri_code) {
                case uri.CGI__USER_GETOPENBYOPENID__CODE:         //获取当前用户是否开通支付产品
                    if(json.ret==200){
                        that.setData({
                            seller:json.data[0][0]
                        })
                        console.log(json.data[0])
                    }
                break;
                case uri.CGI__USER_OPENDCBYPAY__CODE:
                    if(json.ret==200){
                        wx.reLaunch({
                            url:'../me/s_index?sellerid='+that.data.sellerid
                        })
                    }
                break;
            }
        }
    },
    getpayseller:function(){
        util.post(uri.CGI__USER_GETOPENBYOPENID,{openid:util.cache('openid')},uri.CGI__USER_GETOPENBYOPENID__CODE)
    },
    getopendc:function(){
        util.post(uri.CGI__USER_OPENDCBYPAY,{openid:util.cache('openid'),sellerid:this.data.sellerid,username:this.data.username},uri.CGI__USER_OPENDCBYPAY__CODE)
    },
    netchange:function(){
        this.onShow();
    }
})