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

2
common/config.js

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

1
common/request.api.js

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

68
common/wxSilentLogin.js

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

22
pages.json

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

66
pages/index/BindPhone.vue

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

Loading…
Cancel
Save