Commit 3df420bc authored by 李俊赕's avatar 李俊赕

test-util

parent 4f1b13ca
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
//domain_Name: 'http://192.168.0.208:37080', //domain_Name: 'http://192.168.0.208:37080',
token:'', token:'',
//RTOKEN45f41a3053238cb72b3b72fe14df8d7040c9f502 //RTOKEN45f41a3053238cb72b3b72fe14df8d7040c9f502
openId:'',
//定位 图标 //定位 图标
icon_location:'https://qn-static.banshouhui.com/take_order/icon/location.png', icon_location:'https://qn-static.banshouhui.com/take_order/icon/location.png',
...@@ -140,11 +141,10 @@ ...@@ -140,11 +141,10 @@
uni.showLoading({ uni.showLoading({
title:'加载中……' title:'加载中……'
}) })
console.log(vm.$u.api,'this.$u.api')
const res = await vm.$u.api.getSettleBaseInfo() const res = await vm.$u.api.getSettleBaseInfo()
if (!res.status) { if (!res.status) {
uni.showToast({ uni.showToast({
title: res.message, title: res.message || '获取基本信息错误',
icon: 'none' icon: 'none'
}); });
return false; return false;
......
...@@ -77,8 +77,6 @@ const install = (Vue, vm) => { ...@@ -77,8 +77,6 @@ const install = (Vue, vm) => {
Vue.prototype.$u.http.interceptor.request = (config) => { Vue.prototype.$u.http.interceptor.request = (config) => {
const reg = /\?\w+/; const reg = /\?\w+/;
let token = util.getToken() let token = util.getToken()
console.log(token,'token')
// let token = 'RTOKENe56f873b5823477fa2e15572f8fa7eb3a5fb6f7b'
if(!token && noLoginUrl.indexOf(config.url)<0){ if(!token && noLoginUrl.indexOf(config.url)<0){
vm.$u.route('/pages/login/wxlogin'); vm.$u.route('/pages/login/wxlogin');
} }
...@@ -96,26 +94,21 @@ const install = (Vue, vm) => { ...@@ -96,26 +94,21 @@ const install = (Vue, vm) => {
config.header['Authorization'] = token config.header['Authorization'] = token
} }
// // config.header.token = vm.vuex_token || 'RTOKENe56f873b5823477fa2e15572f8fa7eb3a5fb6f7b'; // config.header.token = vm.vuex_token || 'RTOKENe56f873b5823477fa2e15572f8fa7eb3a5fb6f7b';
// 临时测试 token -- 开发环境
// if (apiUrl == 'http://fa.yunya.com') {
// config.header.token = '0edjXh5micAR3Lf1tkNtObcUtLMdiVGCVOxlkca_PyTi0CFdyo5kF3TMdSEO8wBDHJh8CwDOTCfzvpLeavzLNg';
// }
//设置session_id
// config.header.sid = getSessionId(vm);
//config.header.uid = vm.vuex_user.id || 0;
config.header['x-requested-with'] = 'xmlhttprequest'; config.header['x-requested-with'] = 'xmlhttprequest';
// if(config.method=='POST'){
// config.data['__token__'] = vm.vuex__token__;
// }
// if(config.url.indexOf(apiBaseUrl)>=0){
// // 快查相关页面临时参数
// config.header['Authorize'] = vm.vuex_token;
// }
return config; return config;
} }
function getCode(res){
const result = res.data
let code
if(result.hasOwnProperty('code')){
code = result.code
}else if(res.hasOwnProperty('statusCode')){
code = res.statusCode
}
return code
}
// 响应拦截,判断状态码是否通过 // 响应拦截,判断状态码是否通过
Vue.prototype.$u.http.interceptor.response = (res) => { Vue.prototype.$u.http.interceptor.response = (res) => {
let result = res.data; let result = res.data;
...@@ -123,26 +116,33 @@ const install = (Vue, vm) => { ...@@ -123,26 +116,33 @@ const install = (Vue, vm) => {
if (res.header.__token__) { if (res.header.__token__) {
vm.$u.vuex('vuex__token__', res.header.__token__); vm.$u.vuex('vuex__token__', res.header.__token__);
} }
switch (result.code) { const code = getCode(res)
switch (code) {
case 1: case 1:
case 0: case 0:
return result; return result;
case 200:
if(!result.data){
return {
data:res.data,
code:code,
message:res.message || res.errMsg || ''
};
}
return res.data;
case 401: case 401:
//需要登录的接口,当token 过期时,清掉本地token,到登录页面 //需要登录的接口,当token 过期时,清掉本地token,到登录页面
// if (!token) {
///* // uni.navigateTo({
if (!this.vuex_token) { // url: '/pages/login/wxlogin'
uni.navigateTo({ // });
url: '/pages/login/wxlogin' // return;
}); // }
return;
}
//*/
vm.$u.vuex('vuex_token','');
let pages = getCurrentPages(); let pages = getCurrentPages();
if((pages[pages.length - 1]).route!=='pages/login/wxlogin'){ if((pages[pages.length - 1]).route!=='pages/login/wxlogin'){
vm.$u.route('/pages/login/wxlogin'); util.setToken('')
vm.$u.route('/pages/login/wxlogin');
return
} }
return result; return result;
case 403://没有权限访问 case 403://没有权限访问
...@@ -153,20 +153,31 @@ const install = (Vue, vm) => { ...@@ -153,20 +153,31 @@ const install = (Vue, vm) => {
}) })
return result; return result;
default: default:
if (res.statusCode == 200) { return {
if(!result.data){ data:res.data,
return { code:code,
data:res.data, message:res.message || res.errMsg || ''
code:res.statusCode, };
message:res.message || res.errMsg || '' vm.$u.toast('网络请求错误!');
}; // if (res.statusCode == 200) {
} // if(!result.data){
return res.data; // return {
} else if(res.statusCode == 401){ // data:res.data,
vm.$u.route('/pages/login/wxlogin'); // code:res.statusCode,
} else{ // message:res.message || res.errMsg || ''
vm.$u.toast('网络请求错误!'); // };
} // }
// return res.data;
// } else if(res.statusCode == 401){
// vm.$u.route('/pages/login/wxlogin');
// } else{
// return {
// data:res.data,
// code:res.statusCode,
// message:res.message || res.errMsg || ''
// };
// vm.$u.toast('网络请求错误!');
// }
} }
} }
} }
......
...@@ -97,7 +97,7 @@ export default { ...@@ -97,7 +97,7 @@ export default {
let inLen = this.selectNum - this.imgList.length let inLen = this.selectNum - this.imgList.length
if (inLen > 0) { if (inLen > 0) {
item.src = file item.src = file
item.key = res.key item.key = res.key || res.src
this.imgList.push(item); this.imgList.push(item);
this.imgs.push(res.key) this.imgs.push(res.key)
// this.addRecord(item,res) // this.addRecord(item,res)
......
...@@ -280,29 +280,29 @@ ...@@ -280,29 +280,29 @@
"navigationBarTitleText": "uni-app", "navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8", "navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8" "backgroundColor": "#F8F8F8"
},
"condition": { //模式配置,仅开发期间生效
"current": 0, //当前激活的模式(list 的索引项)
"list": [{
"name": "考试", //模式名称
"path": "pages/exam/index", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
},{
"name": "基本信息", //模式名称
"path": "pages/settle/base", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
},{
"name": "资料信息", //模式名称
"path": "pages/settle/file", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
},{
"name": "缴纳保证金", //模式名称
"path": "pages/settle/pay-ensure", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
},{
"name": "签约页面", //模式名称
"path": "pages/settle/sign-contract", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
}]
} }
// "condition": { //模式配置,仅开发期间生效
// "current": 0, //当前激活的模式(list 的索引项)
// "list": [{
// "name": "观看视频", //模式名称
// "path": "pages/video/index", //启动页面,必选
// "query": "" //启动参数,在页面的onLoad函数里面得到
// // },{
// // "name": "基本信息", //模式名称
// // "path": "pages/settle/base", //启动页面,必选
// // "query": "" //启动参数,在页面的onLoad函数里面得到
// },{
// "name": "资料信息", //模式名称
// "path": "pages/settle/file", //启动页面,必选
// "query": "" //启动参数,在页面的onLoad函数里面得到
// },{
// "name": "缴纳保证金", //模式名称
// "path": "pages/settle/pay-ensure", //启动页面,必选
// "query": "" //启动参数,在页面的onLoad函数里面得到
// },{
// "name": "签约页面", //模式名称
// "path": "pages/settle/sign-contract", //启动页面,必选
// "query": "" //启动参数,在页面的onLoad函数里面得到
// }]
// }
} }
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
</template> </template>
<script> <script>
import util from '@/utils/util.js'
export default { export default {
data() { data() {
return { return {
...@@ -34,12 +35,8 @@ ...@@ -34,12 +35,8 @@
getApp().trackPage('授权登录页') getApp().trackPage('授权登录页')
this.icon_notice = getApp().globalData.icon_auth_notice this.icon_notice = getApp().globalData.icon_auth_notice
this.icon_auth_notice_new = getApp().globalData.icon_auth_notice_new this.icon_auth_notice_new = getApp().globalData.icon_auth_notice_new
//this.domain_name = getApp().globalData.domain_Name
//console.log('当前域名:'+this.domain_name)
}, },
methods: { methods: {
//用户授权得到用户的信息 //用户授权得到用户的信息
getUserInfo: async function(e) { getUserInfo: async function(e) {
...@@ -104,7 +101,7 @@ ...@@ -104,7 +101,7 @@
if (res.code == 200) { if (res.code == 200) {
this.unionID = res.data.user.unionid this.unionID = res.data.user.unionid
this.openID = res.data.user.wxopenid this.openID = res.data.user.wxopenid
util.setOpenid(res.data.user.wxopenid)
if (res.data.token) { if (res.data.token) {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
...@@ -132,17 +129,22 @@ ...@@ -132,17 +129,22 @@
saveUserInfo: async function(res) { saveUserInfo: async function(res) {
//console.log('用户信息存本地 token:' +res.data.data.token); //console.log('用户信息存本地 token:' +res.data.data.token);
// this.$u.vuex('vuex_token', res.data.data.token) // this.$u.vuex('vuex_token', res.data.data.token)
uni.setStorage({ console.log('token','token')
key: 'token', util.setToken(res.data.token)
data: res.data.token, // uni.setStorage({
success: function(e) { // key: 'token',
//console.log('保存token 成功'+e); // data: res.data.token,
} // success: function(e) {
}); // //console.log('保存token 成功'+e);
// }
// });
let pages = getCurrentPages(); let pages = getCurrentPages();
let prevPage = pages[pages.length - 2]; //上一个页面 let prevPage = pages[pages.length - 2]; //上一个页面
if (prevPage.route == 'pages/index/index') { // if (prevPage.route == 'pages/index/index') {
// prevPage.$vm.isRefresh = true;
// }
if(prevPage && prevPage.$vm){
prevPage.$vm.isRefresh = true; prevPage.$vm.isRefresh = true;
} }
uni.navigateBack({ uni.navigateBack({
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
<script> <script>
import pingpp from '@/include/libs/pingpp.js' import pingpp from '@/include/libs/pingpp.js'
import globalUrl from '@/common/base_url.js' import globalUrl from '@/common/base_url.js'
import util from '@/utils/util.js'
export default { export default {
data() { data() {
return { return {
...@@ -36,13 +37,25 @@ ...@@ -36,13 +37,25 @@
payResult:{ payResult:{
oid:'' oid:''
}, },
isRefresh:false,
settledInfo:null, settledInfo:null,
} }
}, },
onLoad(e) { onLoad(e) {
this.getBaseInfo()
},
onShow(){
if(!this.settledInfo){
this.getBaseInfo()
}
}, },
computed: {}, computed: {},
watch:{
isRefresh(val){
console.log('isRefresh')
this.getBaseInfo()
}
},
components: { components: {
}, },
...@@ -102,6 +115,33 @@ ...@@ -102,6 +115,33 @@
// } // }
// },1000) // },1000)
}, },
getCode: async function() {
let that = this
uni.showLoading({
title: '加载中',
})
return new Promise((resolve, reject) => {
uni.login({
// #ifdef MP-ALIPAY
scopes: 'auth_user',
// #endif
success: function(res) {
if (res.code) {
resolve(res.code)
//resolve(res.code);
} else {
reject('未取得code');
}
},
fail: function(res) {
reject('用户授权失败wx.login');
},
complete() {
uni.hideLoading()
}
});
});
},
async paySubmit() { async paySubmit() {
const self = this const self = this
this.saving = true this.saving = true
...@@ -109,9 +149,16 @@ ...@@ -109,9 +149,16 @@
title:'支付中……' title:'支付中……'
}) })
// 提交支付订单 // 提交支付订单
// wx_lite
// appid:wxd1d6eede324b0465
const code = await this.getCode()
console.log(code,'code')
const params = { const params = {
oid: this.settledInfo.record.id, oid: this.settledInfo.record.id,
type: 'wx', type: 'wx_lite',
openid:util.getOpenid(),
code:code
// appid:'wxd1d6eede324b0465'
} }
// const codeApiUrl = globalUrl.codeUrl.apiUrl; // const codeApiUrl = globalUrl.codeUrl.apiUrl;
const response = await this.$u.api.paySettleDeposit(params) const response = await this.$u.api.paySettleDeposit(params)
......
...@@ -74,6 +74,11 @@ ...@@ -74,6 +74,11 @@
onLoad(e) { onLoad(e) {
this.getBaseInfo() this.getBaseInfo()
}, },
onShow(){
if(!this.settledInfo){
this.getBaseInfo()
}
},
computed: { computed: {
}, },
components: { components: {
......
...@@ -86,6 +86,11 @@ ...@@ -86,6 +86,11 @@
console.log('onshow') console.log('onshow')
this.getBaseInfo() this.getBaseInfo()
// this.goSign() // this.goSign()
const url = 'https://m.test.ibanshou.cn/activity/settled_2021/mini'
// uni.navigateTo({
// url:'/pages/settle/web?url='+url
// })
// https://m.test.ibanshou.cn/activity/settled_2021/mini
}, },
computed: { computed: {
submitStatus() { submitStatus() {
...@@ -215,8 +220,8 @@ ...@@ -215,8 +220,8 @@
const app = getApp() const app = getApp()
const callBack = (vm,result)=>{ const callBack = (vm,result)=>{
vm.settledInfo = result vm.settledInfo = result
console.log(result,'result--------')
const record = result.record const record = result.record
vm.baseInfo.name = record.id_card_name vm.baseInfo.name = record.id_card_name
vm.baseInfo.id = record.id vm.baseInfo.id = record.id
} }
...@@ -227,6 +232,7 @@ ...@@ -227,6 +232,7 @@
} }
await app.getBaseInfo(this,callBack) await app.getBaseInfo(this,callBack)
}, },
async submitInfo(){ async submitInfo(){
// checkSettleSignInfo // checkSettleSignInfo
......
...@@ -10,6 +10,29 @@ const getToken = function(){ ...@@ -10,6 +10,29 @@ const getToken = function(){
} }
return token return token
} }
const setToken = function(token){
const app = getApp()
uni.setStorageSync('token',token)
if(app && app.globalData){
app.globalData.token = token
}
}
const getOpenid = function(){
const app = getApp()
let openid = app && app.globalData && app.globalData.openid || ''
if(!openid){
openid = uni.getStorageSync('openid')
}
return openid
}
const setOpenid = function(openid){
const app = getApp()
uni.setStorageSync('openid',openid)
if(app && app.globalData){
app.globalData.openid = openid
}
}
module.exports = { module.exports = {
formatTime: function(n) { formatTime: function(n) {
var e = n.getFullYear(), r = n.getMonth() + 1, o = n.getDate(), i = n.getHours(), u = n.getMinutes(), a = n.getSeconds(); var e = n.getFullYear(), r = n.getMonth() + 1, o = n.getDate(), i = n.getHours(), u = n.getMinutes(), a = n.getSeconds();
...@@ -31,5 +54,8 @@ module.exports = { ...@@ -31,5 +54,8 @@ module.exports = {
o = o.substring(0, e), e = (i = 60 * i + "").indexOf("."), i = i.substring(0, e + 4), o = o.substring(0, e), e = (i = 60 * i + "").indexOf("."), i = i.substring(0, e + 4),
i = parseFloat(i).toFixed(0)) : 1 == n && (o = parseFloat(o).toFixed(6))), 2 == n ? r + "°" + o + "′" + i + "″" : 1 == n ? r + "°" + o + "′" : void 0; i = parseFloat(i).toFixed(0)) : 1 == n && (o = parseFloat(o).toFixed(6))), 2 == n ? r + "°" + o + "′" + i + "″" : 1 == n ? r + "°" + o + "′" : void 0;
}, },
getToken getToken,
setToken,
getOpenid,
setOpenid,
}; };
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment