Browse Source

1111

master
wangjiahai 2 years ago
parent
commit
e48b3bb6da
  1. 9
      App.vue
  2. 2
      common/config.js
  3. 1
      common/request.api.js
  4. 68
      common/wxSilentLogin.js
  5. 22
      pages.json
  6. 66
      pages/index/BindPhone.vue

9
App.vue

@ -1,13 +1,12 @@
<script>
import config from "common/config.js";
export default {
globalData: {
wxSilentLoginURL: config.baseUrl+"/v1/app/wxuser/wxSilentLogin",
},
globalData: {
wxSilentLoginURL: config.baseUrl + "/lpkcustomer/wxSilentLogin",
sid: ""
},
onLaunch: function() {
this.WxSilentLogin()
},
onShow: function() {
console.log('App Show')

2
common/config.js

@ -6,7 +6,7 @@
* loginTimeoutPage = "/pages/login/index", // 登录超时或失效的情况下,跳转到的登录页面
*/
module.exports = {
baseUrl: 'http://192.168.1.193:7201',
baseUrl: 'http://192.168.0.108:7201',
// baseUrl: 'https://jianguan.yyundong.com',
// baseUrl: 'http://jianguan.yyundong.com/api',
tokenName: "Authorization", // 请求头中token的名字,与服务器端对应

1
common/request.api.js

@ -2,6 +2,7 @@ import request from '@/utils/requester.js'
export default {
login: (params = {}) => request.post("/wxmpapi/sysuser/login", params),
wxBindMobile: (params = {}) => request.post("/lpkcustomer/wxBindMobile", params),
sayhello: (params = {}) => request.get("/sayb", params),
getSalesReport: (params = {}) => request.get("/system/reportCenter/getSalesReport", params),
getGoodsOnWay: (params = {}) => request.get("/system/reportCenter/getGoodsOnWay", params),

68
common/wxSilentLogin.js

@ -1,4 +1,3 @@
const wxSilentLogin = () => {
return new Promise((resolve, reject) => {
wx.login({
@ -30,58 +29,47 @@ const wxSilentLogin = () => {
if (res.statusCode == 200) {
if (!res.data.success) {
// if (res.data.code == 500) {
// uni.showModal({
// title: '温馨提示',
// content: '您的平台应用未被授权,请联系工作人员。',
// showCancel: false,
// success: function(res) {
// if (res.confirm) {
// wx.exitMiniProgram({
// success: function() {},
// fail: function() {}
// })
// } else {
// console.log('点击了取消')
// }
// }
// })
if (res.data.code == "110") {
console.log(res.data.data);
// 未绑定用户
// uni.navigateTo({
// url: '/pages/index/BindPhone?openid=' +
// res.data.data.wxMpOpenid
// })
// return
// }
// if (res.data.code == 100) {
// 未绑定用户
uni.navigateTo({
url: '../index/BindPhone?openid=' +
res.data.data.openid+"&unionid="+
res.data.data.unionid
})
// }
uni.navigateTo({
url: '/pages/index/BindPhone?openid=' +
res.data.data.wxMpOpenid
})
}
} else {
console.log("Http网络请求res", res)
console.log("Global-Auth-Token", res.data.data
.token)
getApp().globalData.username = res.data.data
.name
getApp().globalData.token = res.data.data.token
getApp().globalData.sid = res.data.data.sid
getApp().globalData.mobile = res.data.data
.mobile
getApp().globalData.isAdmin = res.data.data.isAdmin
getApp().globalData.orgSidPath = res.data.data.orgSidPath
getApp().globalData.orgNamePath = res.data.data.orgNamePath
getApp().globalData.organizationSid = res.data.data.organizationSid
getApp().globalData.headImage = res.data.data.headImage
getApp().globalData.isLogin = true
getApp().globalData.isAdmin = res.data.data
.isAdmin
getApp().globalData.orgSidPath = res.data.data
.orgSidPath
getApp().globalData.orgNamePath = res.data.data
.orgNamePath
getApp().globalData.organizationSid = res.data
.data.organizationSid
getApp().globalData.headImage = res.data.data
.headImage
getApp().globalData.isLogin = true
uni.setStorageSync("Global-Auth-Token", res.data
.data.token)
uni.setStorageSync("sid", res.data.data.sid)

22
pages.json

@ -15,7 +15,16 @@
"scrollIndicator": false //,
}
}
},
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "绑定账号",
"navigationStyle": "custom",
"app-plus": {
"scrollIndicator": false //,
}
}
}
],
"globalStyle": {
@ -31,19 +40,10 @@
"backgroundColor": "#ffffff",
"list": [{
"pagePath": "pages/card/card",
"iconPath": "static/home_n.png",
"selectedIconPath": "static/home_s.png",
"text": "首页"
}, {
"pagePath": "pages/index/msg",
"iconPath": "static/msg_n.png",
"selectedIconPath": "static/msg_s.png",
"pagePath": "pages/index/index",
"text": "通知"
}, {
"pagePath": "pages/index/me",
"iconPath": "static/me_n.png",
"selectedIconPath": "static/me_s.png",
"text": "我的"
}]
},
"uniIdRouter": {}

66
pages/index/BindPhone.vue

@ -19,24 +19,24 @@
</view>
<view class="inputRow">
<!-- <view class="inputRow">
<image src="../../static/baseIcon/code.png" mode="aspectFill" class="drawableLeft"></image>
<input type="number" @input="codeText" maxlength="6" placeholder="请输入验证码" class="input" />
</view>
</view> -->
<view class="btn" @click="next">
<text class="btnText">绑定账号</text>
</view>
<view v-show="!isShow">
<view v-show="!isShow">
<view style="display: flex;flex-direction: column;justify-content: center;width: 100%;margin-top: 50px;">
<text style="width: 100%;text-align: center;font-size: 35px;color: #f00;">抱歉</text>
<text style="margin: 20px; text-align: center;font-size: 30px;color: #f00;">您的平台应用未被授权请联系工作人员</text>
</view>
</view>
</view>
</template>
@ -45,7 +45,7 @@
export default {
data() {
return {
isShow:true,
isShow: true,
//
statusBarHeight: 0,
//
@ -54,25 +54,15 @@
mobile: '',
openid: '',
code: '',
unionid:""
unionid: ""
}
};
},
//
created() {
//
this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
this.$bus.$on('isShow', msg => {
//httpjswholeSpin
console.log("isShows>>>>>", msg)
this.isShow = msg
console.log("isShows>>>>>", this.isShow)
});
},
onShow() {
/* #ifdef MP-WEIXIN */
@ -80,44 +70,44 @@
/* #endif */
},
onLoad(options) {
console.log('=======', options)
console.log('=======', options)
this.page.openid = options.openid
this.page.unionid = options.unionid
console.log('this.page', this.page)
console.log('this.page', this.page)
},
methods: {
next() {
var mobileLength = this.page.mobile.length;
var codeLength = this.page.code.length;
if (mobileLength == 0) {
this.Toast("请输入手机号")
return;
}
if (codeLength == 0) {
this.Toast("验证码不能为空")
uni.showToast({
icon: 'error',
title: '手机号不能为空'
})
return;
}
let _this = this
console.log('1111', _this.page)
_this.$api.wxBindMobile(_this.page).then((resp) => {
// if (resp.success) {
console.log('1111', resp)
getApp().globalData.username = resp.userName
getApp().globalData.token = resp.token
getApp().globalData.sid = resp.sid
getApp().globalData.mobile = resp.mobile
getApp().globalData.isLogin = true
getApp().globalData.sid = resp
// getApp().globalData.token = resp.token
// getApp().globalData.sid = resp.sid
// getApp().globalData.mobile = resp.mobile
// getApp().globalData.isLogin = true
// _this.WritePreference("sysUserSid", res.data)
// _this.WritePreference("isLogin", true)
// getApp().globalData.isLogin = true
// getApp().globalData.sysUserSid = res.data
uni.navigateBack({
delta: 10,
});
uni.switchTab({
url: '/pages/card/card'
})
// uni.switchTab({
// url: '/pages/home/WorkFragment'
@ -130,7 +120,7 @@
// showCancel: false,
// success: function(res) {
// if (res.confirm) {
// } else {
// console.log('')
// }
@ -179,8 +169,8 @@
send(e) { //
console.log(e);
this.isShow = e.success
console.log("this.isShow",this.isShow);
console.log("this.isShow", this.isShow);
},
codeText(e) {
//

Loading…
Cancel
Save