Commit 680761ef authored by 潘永坪's avatar 潘永坪

登录功能完善

parent 9cdd0684
......@@ -6,10 +6,10 @@
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
export default {
onLaunch: function() {//初始化完成时触发(全局只触发一次
console.log('App Launch')
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
......
......@@ -51,7 +51,7 @@
</view> -->
<!-- <button @click="getUserInfo()"> 授权获取头像昵称 </button> -->
<view class="bottom">
<view class="bottom" v-show="showBottom">
<!--#ifdef MP-WEIXIN -->
<web-view src="https://wx.pangdly.com"></web-view>
<!--#endif-->
......@@ -67,66 +67,36 @@
export default {
data() {
return {
title: '胖丁首页'
title: '胖丁首页',
showBottom:false,//控制底部显示隐藏
}
},
onReady(){
//#ifdef MP-WEIXIN
onLoad() {
let _this=this
uni.login({
provider: 'weixin',
success: function (res) {
if(res.code){
let data={
code:res.code,
source:3
}
_this.$request('wechat/wx/getUserInfoByCode',data).then(res => {
if(res.code=='00'){
let openid=res.data.openid
uni.setStorageSync('openid',openid)
}else{
uni.removeStorageSync('openid')
uni.showToast({
title:res.message,
icon:"none"
})
}
}).catch((err)=>{
uni.removeStorageSync('openid')
})
}
}
//#ifdef MP-WEIXIN
uni.checkSession({
success() {
_this.showBottom=true
},
fail() {
uni.navigateTo({
url:"../login/login"
})
}
})
//#endif
//#ifdef MP-ALIPAY
let _this=this
uni.login({
provider: 'alipay',
success: function(res){
if(res.code){
let data={
code:res.code,
source:3
}
_this.$request('wechat/wx/getUserInfoByCode',data).then(res => {
if(res.code=='00'){
let openid=res.data.openid
uni.setStorageSync('openid',openid)
}else{
uni.removeStorageSync('openid')
uni.showToast({
title:res.message,
icon:"none"
})
}
}).catch((err)=>{
uni.removeStorageSync('openid')
})
}
}
})
if(uni.getStorageSync("openid")){
_this.showBottom=true
}else{
uni.navigateTo({
url:"../login/login"
})
}
//#endif
},
onReady(){
},
methods: {
getUserInfo() { // 获取用户信息
......
......@@ -14,35 +14,47 @@
methods: {
},
onReady(){
//#ifdef MP-WEIXIN
onLoad(){
uni.showLoading({
title: '加载中...'
})
let _this=this
uni.login({
provider: 'weixin',
success: function (res) {
if(res.code){
let data={
code:res.code,
source:3
}
_this.$request('wechat/wx/getUserInfoByCode',data).then(res => {
if(res.code=='00'){
let openid=res.data.openid
uni.setStorageSync('openid',openid)
}else{
uni.removeStorageSync('openid')
uni.showToast({
title:res.message,
icon:"none"
})
uni.getProvider({
service: 'oauth',
success(proRes){
uni.login({
provider:proRes.provider[0],
success: function (res) {
if(res.code){
let data={
code:res.code,
source:3
}
_this.$request('wechat/wx/getUserInfoByCode',data).then(res => {
if(res.code=='00'){
let openid=res.data.openid
uni.setStorageSync('openid',openid)
uni.navigateBack({
delta:1
})
}else{
uni.removeStorageSync('openid')
uni.showToast({
title:res.message,
icon:"none"
})
uni.hideLoading()
}
}).catch((err)=>{
uni.removeStorageSync('openid')
uni.hideLoading()
})
}
}).catch((err)=>{
uni.removeStorageSync('openid')
})
}
}
}
})
}
})
//#endif
},
}
</script>
......
{
"ignoreWebViewDomainCheck": true
}
\ No newline at end of file
const g = typeof global !== 'undefined' ? global : self;
g.appXAppJson = {
"app": {
"$homepage": "pages/index/index"
}
};
if(!self.Map || !self.Set || !self.Symbol) {
importScripts('https://gw.alipayobjects.com/as/g/appx_release/deps/1.0.3/es6-set-map-symbol.js');
}
importScripts(`https://appx/af-appx.worker.min.js`);
require('@alipay/appx-compiler/lib/sjsEnvInit');
require('./config$');
require('../../pages/index/index?hash=32d7d2807ed4e666ef03b4b3fe8c38ecf2e34e68');
require('../../pages/payment/payment?hash=32d7d2807ed4e666ef03b4b3fe8c38ecf2e34e68');
require('../../pages/login/login?hash=32d7d2807ed4e666ef03b4b3fe8c38ecf2e34e68');
require('../../pages/paySuccess/paySuccess?hash=32d7d2807ed4e666ef03b4b3fe8c38ecf2e34e68');
......@@ -99,10 +99,10 @@ Object.defineProperty(exports, "__esModule", { value: true });exports.default =
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
var _default = {
onLaunch: function onLaunch() {//初始化完成时触发(全局只触发一次
console.log('App Launch');
},
onShow: function onShow() {
console.log('App Show');
},
onHide: function onHide() {
console.log('App Hide');
......
......@@ -10,6 +10,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });exports.createApp = createApp;exports.createComponent = createComponent;exports.createPage = createPage;exports.createPlugin = createPlugin;exports.createSubpackageApp = createSubpackageApp;exports.default = void 0;var _vue = _interopRequireDefault(__webpack_require__(/*! vue */ 2));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _slicedToArray(arr, i) {return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _iterableToArrayLimit(arr, i) {if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"] != null) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}function _arrayWithHoles(arr) {if (Array.isArray(arr)) return arr;}function _defineProperty(obj, key, value) {if (key in obj) {Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });} else {obj[key] = value;}return obj;}function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}function _createClass(Constructor, protoProps, staticProps) {if (protoProps) _defineProperties(Constructor.prototype, protoProps);if (staticProps) _defineProperties(Constructor, staticProps);return Constructor;}function _toConsumableArray(arr) {return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();}function _nonIterableSpread() {throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o, minLen) {if (!o) return;if (typeof o === "string") return _arrayLikeToArray(o, minLen);var n = Object.prototype.toString.call(o).slice(8, -1);if (n === "Object" && o.constructor) n = o.constructor.name;if (n === "Map" || n === "Set") return Array.from(o);if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);}function _iterableToArray(iter) {if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);}function _arrayWithoutHoles(arr) {if (Array.isArray(arr)) return _arrayLikeToArray(arr);}function _arrayLikeToArray(arr, len) {if (len == null || len > arr.length) len = arr.length;for (var i = 0, arr2 = new Array(len); i < len; i++) {arr2[i] = arr[i];}return arr2;}
function b64DecodeUnicode(str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
function getCurrentUserInfo() {
var token = my.getStorageSync('uni_id_token') || '';
var tokenArr = token.split('.');
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0 };
}
var userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message);
}
userInfo.tokenExpired = userInfo.exp * 1000;
delete userInfo.exp;
delete userInfo.iat;
return userInfo;
}
function uniIdMixin(Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {var _getCurrentUserInfo =
getCurrentUserInfo(),role = _getCurrentUserInfo.role;
return role.indexOf(roleId) > -1;
};
Vue.prototype.uniIDHasPermission = function (permissionId) {var _getCurrentUserInfo2 =
getCurrentUserInfo(),permission = _getCurrentUserInfo2.permission;
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1;
};
Vue.prototype.uniIDTokenValid = function () {var _getCurrentUserInfo3 =
getCurrentUserInfo(),tokenExpired = _getCurrentUserInfo3.tokenExpired;
return tokenExpired > Date.now();
};
}
var _toString = Object.prototype.toString;
var hasOwnProperty = Object.prototype.hasOwnProperty;
......@@ -940,6 +990,23 @@ var protocols = { // 需要做转换的 API 列表
} },
getUserProfile: {
name: my.canIUse('getOpenUserInfo') ? 'getOpenUserInfo' : 'getAuthUserInfo',
returnValue: function returnValue(result) {
if (my.canIUse('getOpenUserInfo')) {
var response = {};
try {
response = JSON.parse(result.response).response;
} catch (e) {}
result.nickName = response.nickName;
result.avatar = response.avatar;
}
result.userInfo = {
nickName: result.nickName,
avatarUrl: result.avatar };
} },
requestPayment: {
name: 'tradePay',
args: {
......@@ -1992,6 +2059,7 @@ function parseBaseApp(vm, _ref6)
if (vm.$options.store) {
_vue.default.prototype.$store = vm.$options.store;
}
uniIdMixin(_vue.default);
_vue.default.prototype.mpHost = "mp-alipay";
......
<view class="bottom"><web-view src="https://wx.pangdly.com"></web-view></view>
\ No newline at end of file
<view hidden="{{!(showBottom)}}" class="bottom"><web-view src="https://wx.pangdly.com"></web-view></view>
\ No newline at end of file
......@@ -205,25 +205,12 @@ var _default =
{
data: function data() {
return {
title: '胖丁首页' };
title: '胖丁首页',
showBottom: false //控制底部显示隐藏
};
},
onReady: function onReady() {
onLoad: function onLoad() {
var _this = this;
......@@ -237,33 +224,16 @@ var _default =
if (uni.getStorageSync("openid")) {
_this.showBottom = true;
} else {
uni.navigateTo({
url: "../login/login" });
var _this = this;
uni.login({
provider: 'alipay',
success: function success(res) {
if (res.code) {
var data = {
code: res.code,
source: 3 };
_this.$request('wechat/wx/getUserInfoByCode', data).then(function (res) {
if (res.code == '00') {
var openid = res.data.openid;
uni.setStorageSync('openid', openid);
} else {
uni.removeStorageSync('openid');
uni.showToast({
title: res.message,
icon: "none" });
}
}).catch(function (err) {
uni.removeStorageSync('openid');
});
}
} });
}
},
onReady: function onReady() {
},
methods: {
......
......@@ -128,7 +128,7 @@ __webpack_require__.r(__webpack_exports__);
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0; //
/* WEBPACK VAR INJECTION */(function(uni) {Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0; //
//
//
//
......@@ -144,36 +144,49 @@ var _default =
methods: {},
onReady: function onReady() {
onLoad: function onLoad() {
uni.showLoading({
title: '加载中...' });
var _this = this;
uni.getProvider({
service: 'oauth',
success: function success(proRes) {
uni.login({
provider: proRes.provider[0],
success: function success(res) {
if (res.code) {
var data = {
code: res.code,
source: 3 };
_this.$request('wechat/wx/getUserInfoByCode', data).then(function (res) {
if (res.code == '00') {
var openid = res.data.openid;
uni.setStorageSync('openid', openid);
uni.navigateBack({
delta: 1 });
} else {
uni.removeStorageSync('openid');
uni.showToast({
title: res.message,
icon: "none" });
uni.hideLoading();
}
}).catch(function (err) {
uni.removeStorageSync('openid');
uni.hideLoading();
});
}
} });
} });
} };exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-alipay/dist/index.js */ 1)["default"]))
/***/ })
......
......@@ -99,10 +99,10 @@ Object.defineProperty(exports, "__esModule", { value: true });exports.default =
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
var _default = {
onLaunch: function onLaunch() {//初始化完成时触发(全局只触发一次
console.log('App Launch');
},
onShow: function onShow() {
console.log('App Show');
},
onHide: function onHide() {
console.log('App Hide');
......
......@@ -10,6 +10,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });exports.createApp = createApp;exports.createComponent = createComponent;exports.createPage = createPage;exports.createPlugin = createPlugin;exports.createSubpackageApp = createSubpackageApp;exports.default = void 0;var _vue = _interopRequireDefault(__webpack_require__(/*! vue */ 2));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function ownKeys(object, enumerableOnly) {var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {var symbols = Object.getOwnPropertySymbols(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return Object.getOwnPropertyDescriptor(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function _objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {ownKeys(Object(source), true).forEach(function (key) {_defineProperty(target, key, source[key]);});} else if (Object.getOwnPropertyDescriptors) {Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));} else {ownKeys(Object(source)).forEach(function (key) {Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));});}}return target;}function _slicedToArray(arr, i) {return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _iterableToArrayLimit(arr, i) {if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"] != null) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}function _arrayWithHoles(arr) {if (Array.isArray(arr)) return arr;}function _defineProperty(obj, key, value) {if (key in obj) {Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });} else {obj[key] = value;}return obj;}function _toConsumableArray(arr) {return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();}function _nonIterableSpread() {throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o, minLen) {if (!o) return;if (typeof o === "string") return _arrayLikeToArray(o, minLen);var n = Object.prototype.toString.call(o).slice(8, -1);if (n === "Object" && o.constructor) n = o.constructor.name;if (n === "Map" || n === "Set") return Array.from(o);if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);}function _iterableToArray(iter) {if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);}function _arrayWithoutHoles(arr) {if (Array.isArray(arr)) return _arrayLikeToArray(arr);}function _arrayLikeToArray(arr, len) {if (len == null || len > arr.length) len = arr.length;for (var i = 0, arr2 = new Array(len); i < len; i++) {arr2[i] = arr[i];}return arr2;}
function b64DecodeUnicode(str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
function getCurrentUserInfo() {
var token = wx.getStorageSync('uni_id_token') || '';
var tokenArr = token.split('.');
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0 };
}
var userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message);
}
userInfo.tokenExpired = userInfo.exp * 1000;
delete userInfo.exp;
delete userInfo.iat;
return userInfo;
}
function uniIdMixin(Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {var _getCurrentUserInfo =
getCurrentUserInfo(),role = _getCurrentUserInfo.role;
return role.indexOf(roleId) > -1;
};
Vue.prototype.uniIDHasPermission = function (permissionId) {var _getCurrentUserInfo2 =
getCurrentUserInfo(),permission = _getCurrentUserInfo2.permission;
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1;
};
Vue.prototype.uniIDTokenValid = function () {var _getCurrentUserInfo3 =
getCurrentUserInfo(),tokenExpired = _getCurrentUserInfo3.tokenExpired;
return tokenExpired > Date.now();
};
}
var _toString = Object.prototype.toString;
var hasOwnProperty = Object.prototype.hasOwnProperty;
......@@ -822,7 +872,7 @@ function initData(vueOptions, context) {
try {
data = data.call(context); // 支持 Vue.prototype 上挂的数据
} catch (e) {
if (Object({"VUE_APP_NAME":"uni-pdtravel","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG) {
if (Object({"NODE_ENV":"development","VUE_APP_NAME":"uni-pdtravel","VUE_APP_PLATFORM":"mp-weixin","BASE_URL":"/"}).VUE_APP_DEBUG) {
console.warn('根据 Vue 的 data 函数初始化小程序 data 失败,请尽量确保 data 函数中不访问 vm 对象,否则可能影响首次数据渲染速度。', data);
}
}
......@@ -1355,6 +1405,7 @@ function parseBaseApp(vm, _ref3)
if (vm.$options.store) {
_vue.default.prototype.$store = vm.$options.store;
}
uniIdMixin(_vue.default);
_vue.default.prototype.mpHost = "mp-weixin";
......@@ -7395,7 +7446,7 @@ function type(obj) {
function flushCallbacks$1(vm) {
if (vm.__next_tick_callbacks && vm.__next_tick_callbacks.length) {
if (Object({"VUE_APP_NAME":"uni-pdtravel","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG) {
if (Object({"NODE_ENV":"development","VUE_APP_NAME":"uni-pdtravel","VUE_APP_PLATFORM":"mp-weixin","BASE_URL":"/"}).VUE_APP_DEBUG) {
var mpInstance = vm.$scope;
console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid +
']:flushCallbacks[' + vm.__next_tick_callbacks.length + ']');
......@@ -7416,14 +7467,14 @@ function nextTick$1(vm, cb) {
//1.nextTick 之前 已 setData 且 setData 还未回调完成
//2.nextTick 之前存在 render watcher
if (!vm.__next_tick_pending && !hasRenderWatcher(vm)) {
if(Object({"VUE_APP_NAME":"uni-pdtravel","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG){
if(Object({"NODE_ENV":"development","VUE_APP_NAME":"uni-pdtravel","VUE_APP_PLATFORM":"mp-weixin","BASE_URL":"/"}).VUE_APP_DEBUG){
var mpInstance = vm.$scope;
console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid +
']:nextVueTick');
}
return nextTick(cb, vm)
}else{
if(Object({"VUE_APP_NAME":"uni-pdtravel","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG){
if(Object({"NODE_ENV":"development","VUE_APP_NAME":"uni-pdtravel","VUE_APP_PLATFORM":"mp-weixin","BASE_URL":"/"}).VUE_APP_DEBUG){
var mpInstance$1 = vm.$scope;
console.log('[' + (+new Date) + '][' + (mpInstance$1.is || mpInstance$1.route) + '][' + vm._uid +
']:nextMPTick');
......@@ -7509,7 +7560,7 @@ var patch = function(oldVnode, vnode) {
});
var diffData = this.$shouldDiffData === false ? data : diff(data, mpData);
if (Object.keys(diffData).length) {
if (Object({"VUE_APP_NAME":"uni-pdtravel","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG) {
if (Object({"NODE_ENV":"development","VUE_APP_NAME":"uni-pdtravel","VUE_APP_PLATFORM":"mp-weixin","BASE_URL":"/"}).VUE_APP_DEBUG) {
console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + this._uid +
']差量更新',
JSON.stringify(diffData));
......
......@@ -205,38 +205,36 @@ var _default =
{
data: function data() {
return {
title: '胖丁首页' };
title: '胖丁首页',
showBottom: false //控制底部显示隐藏
};
},
onReady: function onReady() {
onLoad: function onLoad() {
var _this = this;
uni.login({
provider: 'weixin',
success: function success(res) {
if (res.code) {
var data = {
code: res.code,
source: 3 };
_this.$request('wechat/wx/getUserInfoByCode', data).then(function (res) {
if (res.code == '00') {
var openid = res.data.openid;
uni.setStorageSync('openid', openid);
} else {
uni.removeStorageSync('openid');
uni.showToast({
title: res.message,
icon: "none" });
}
}).catch(function (err) {
uni.removeStorageSync('openid');
});
}
uni.checkSession({
success: function success() {
_this.showBottom = true;
},
fail: function fail() {
uni.navigateTo({
url: "../login/login" });
} });
},
onReady: function onReady() {
},
methods: {
getUserInfo: function getUserInfo() {// 获取用户信息
......
<view class="bottom"><web-view src="https://wx.pangdly.com"></web-view></view>
\ No newline at end of file
<view hidden="{{!(showBottom)}}" class="bottom"><web-view src="https://wx.pangdly.com"></web-view></view>
\ No newline at end of file
......@@ -144,32 +144,44 @@ var _default =
methods: {},
onReady: function onReady() {
onLoad: function onLoad() {
uni.showLoading({
title: '加载中...' });
var _this = this;
uni.login({
provider: 'weixin',
success: function success(res) {
if (res.code) {
var data = {
code: res.code,
source: 3 };
_this.$request('wechat/wx/getUserInfoByCode', data).then(function (res) {
if (res.code == '00') {
var openid = res.data.openid;
uni.setStorageSync('openid', openid);
} else {
uni.removeStorageSync('openid');
uni.showToast({
title: res.message,
icon: "none" });
uni.getProvider({
service: 'oauth',
success: function success(proRes) {
uni.login({
provider: proRes.provider[0],
success: function success(res) {
if (res.code) {
var data = {
code: res.code,
source: 3 };
_this.$request('wechat/wx/getUserInfoByCode', data).then(function (res) {
if (res.code == '00') {
var openid = res.data.openid;
uni.setStorageSync('openid', openid);
uni.navigateBack({
delta: 1 });
} else {
uni.removeStorageSync('openid');
uni.showToast({
title: res.message,
icon: "none" });
uni.hideLoading();
}
}).catch(function (err) {
uni.removeStorageSync('openid');
uni.hideLoading();
});
}
}).catch(function (err) {
uni.removeStorageSync('openid');
});
}
} });
} });
......
......@@ -137,12 +137,12 @@ Object.defineProperty(exports, "__esModule", { value: true });exports.default =
var _default =
{
data: function data() {
return {
order: "" };
return {};
},
onLoad: function onLoad(option) {
this.order = option.order;
},
methods: {} };exports.default = _default;
......
<view><web-view src="{{'https://wx.pangdly.com/#/paySuccess?order='+order}}"></web-view></view>
\ No newline at end of file
<view><web-view src="https://wx.pangdly.com/#/paySuccess"></web-view></view>
\ No newline at end of file
......@@ -231,7 +231,6 @@ var _default =
{
data: function data() {
return {
orderId: "", //订单id
merchantName: "", //商户名称
productName: "", //产品名称
orderList: "", //订单列表
......@@ -252,7 +251,7 @@ var _default =
},
onLoad: function onLoad(option) {var _this = this;
var data = {
orderId: option.order, //订单Id
orderId: option.orderId, //订单Id
userId: uni.getStorageSync("openid"), //用户Id
payType: 42 //支付类型
};
......@@ -301,7 +300,7 @@ var _default =
paySign: this.paySign,
success: function success(res) {
uni.redirectTo({
url: 'paySuccess?orderId=123456' });
url: "../paySuccess/paySuccess" });
},
fail: function fail(err) {
......
......@@ -42,6 +42,8 @@
"libVersion": "",
"appid": "wxe678d5240e98a7b8",
"projectname": "uni-pdtravel",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"list": []
......
......@@ -11,20 +11,7 @@
"list": []
},
"miniprogram": {
"list": [
{
"name": "pages/index/index",
"pathName": "pages/index/index",
"query": "",
"scene": null
},
{
"name": "pages/payment/payment",
"pathName": "pages/payment/payment",
"query": "",
"scene": null
}
]
"list": []
}
}
}
\ 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