修复小程序授权和获取微信地址

This commit is contained in:
sugar1569 2018-11-02 12:02:56 +08:00
parent 38ac4ba738
commit 5c6d58d1d1
11 changed files with 114 additions and 40 deletions

View File

@ -1,5 +1,6 @@
express_icon.jpgexpress_icon.jpgexpress_{
"pages": [
"pages/loading/loading",
"pages/load/load",
"pages/login-status/login-status",
"pages/payment/payment",

View File

@ -37,7 +37,7 @@ Page({
method: 'POST',
data: {
address: addressP,
is_default: 0,
is_default: 1,
real_name: res.userName,
post_code: res.postalCode,
phone: res.telNumber,
@ -85,25 +85,14 @@ Page({
header: header,
success: function (res) {
if (res.data.code == 200) {
if (res.data.data.length < 1) {
wx.showToast({
title: '暂无收货地址,请先添加收货地址',
icon: 'none',
duration: 1000,
})
setTimeout(function () {
that.addAddress();
}, 1100)
} else {
that.setData({
addressArray: res.data.data
})
for (var i in res.data.data){
if (res.data.data[i].is_default){
that.setData({
_num: res.data.data[i].id
})
}
that.setData({
addressArray: res.data.data
})
for (var i in res.data.data) {
if (res.data.data[i].is_default) {
that.setData({
_num: res.data.data[i].id
})
}
}
}

4
view/crmebN/pages/load/load.js Normal file → Executable file
View File

@ -3,14 +3,12 @@ Page({
data: {
logo: '',
name: '',
spid: 0,
url: app.globalData.url,
},
onLoad: function (options) {
var that = this;
that.getEnterLogo();
app.setBarColor();
if (options.scene) that.data.spid = options.scene;
},
getEnterLogo: function () {
var that = this;
@ -29,7 +27,7 @@ Page({
//获取用户信息并且授权
getUserInfo: function(e){
var userInfo = e.detail.userInfo;
userInfo.spid = this.data.spid;
userInfo.spid = app.globalData.spid;
wx.login({
success: function (res) {
if (res.code) {

0
view/crmebN/pages/load/load.json Normal file → Executable file
View File

0
view/crmebN/pages/load/load.wxml Normal file → Executable file
View File

6
view/crmebN/pages/load/load.wxss Normal file → Executable file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,87 @@
// pages/load/load.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
logo: '',
name: '',
url: app.globalData.url,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this;
app.setBarColor();
if (options.scene) app.globalData.spid = options.scene;
that.setSetting();
},
setSetting: function () {
var that = this;
wx.getSetting({
success(res) {
if (!res.authSetting['scope.userInfo']){
wx.navigateTo({
url: '/pages/load/load',
})
}else{
that.getUserInfo();
}
}
})
},
getUserInfo: function () {
var that = this;
wx.getUserInfo({
lang: 'zh_CN',
success: function (res) {
var userInfo = res.userInfo
wx.login({
success: function (res) {
if (res.code) {
userInfo.code = res.code;
userInfo.spid = app.globalData.spid;
wx.request({
url: app.globalData.url + '/routine/login/index',
method: 'post',
dataType  : 'json',
data: {
info: userInfo
},
success: function (res) {
app.globalData.uid = res.data.data.uid;
if (app.globalData.openPages != '' && app.globalData.openPages != undefined) {//跳转到指定页面
wx.navigateTo({
url: app.globalData.openPages
})
} else {//跳转到首页
wx.reLaunch({
url: '/pages/index/index'
})
}
},
})
} else {
console.log('登录失败!' + res.errMsg)
}
},
fail: function () {
},
})
},
fail: function () {
},
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
})

View File

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "引导页"
}

View File

@ -0,0 +1,4 @@
<view class='loading-pic'>
<image src='/images/long.gif'></image>
<!-- <view>正在加载中...</view> -->
</view>

View File

@ -0,0 +1,3 @@
.loading-pic{position:fixed;top:0;left:0;right:0;bottom:0;background-color:#fff;}
.loading-pic image{width:190rpx;height:190rpx;position:fixed;top:50%;left:50%;margin-left:-95rpx;margin-top:-95rpx;}
.loading-pic view{width:190rpx;height:190rpx;position:fixed;top:68%;left:52%;margin-left:-95rpx;margin-top:-95rpx;}

View File

@ -287,20 +287,9 @@ Page({
header: header,
success: function (res) {
if (res.data.code == 200) {
if (res.data.data.length < 1) {
wx.showToast({
title: '暂无收货地址,请先添加收货地址',
icon: 'none',
duration: 1000,
})
setTimeout(function () {
that.toAddress();
}, 1100)
} else {
wx.navigateTo({ //跳转至指定页面并关闭其他打开的所有页面(这个最好用在返回至首页的的时候)
url: '/pages/address/address?cartId=' + that.data.cartId + '&pinkId=' + that.data.pinkId + '&couponId=' + that.data.couponId
})
}
wx.navigateTo({ //跳转至指定页面并关闭其他打开的所有页面(这个最好用在返回至首页的的时候)
url: '/pages/address/address?cartId=' + that.data.cartId + '&pinkId=' + that.data.pinkId + '&couponId=' + that.data.couponId
})
}
}
})