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

登录功能完善

parent 9cdd0684
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全 //4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
export default { export default {
onLaunch: function() {//初始化完成时触发(全局只触发一次 onLaunch: function() {//初始化完成时触发(全局只触发一次
console.log('App Launch')
}, },
onShow: function() { onShow: function() {
console.log('App Show')
}, },
onHide: function() { onHide: function() {
console.log('App Hide') console.log('App Hide')
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
</view> --> </view> -->
<!-- <button @click="getUserInfo()"> 授权获取头像昵称 </button> --> <!-- <button @click="getUserInfo()"> 授权获取头像昵称 </button> -->
<view class="bottom"> <view class="bottom" v-show="showBottom">
<!--#ifdef MP-WEIXIN --> <!--#ifdef MP-WEIXIN -->
<web-view src="https://wx.pangdly.com"></web-view> <web-view src="https://wx.pangdly.com"></web-view>
<!--#endif--> <!--#endif-->
...@@ -67,66 +67,36 @@ ...@@ -67,66 +67,36 @@
export default { export default {
data() { data() {
return { return {
title: '胖丁首页' title: '胖丁首页',
showBottom:false,//控制底部显示隐藏
} }
}, },
onReady(){ onLoad() {
//#ifdef MP-WEIXIN
let _this=this let _this=this
uni.login({ //#ifdef MP-WEIXIN
provider: 'weixin', uni.checkSession({
success: function (res) { success() {
if(res.code){ _this.showBottom=true
let data={ },
code:res.code, fail() {
source:3 uni.navigateTo({
} url:"../login/login"
_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')
}) })
} }
}
}) })
//#endif //#endif
//#ifdef MP-ALIPAY //#ifdef MP-ALIPAY
let _this=this if(uni.getStorageSync("openid")){
uni.login({ _this.showBottom=true
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{ }else{
uni.removeStorageSync('openid') uni.navigateTo({
uni.showToast({ url:"../login/login"
title:res.message,
icon:"none"
}) })
} }
}).catch((err)=>{
uni.removeStorageSync('openid')
})
}
}
})
//#endif //#endif
},
onReady(){
}, },
methods: { methods: {
getUserInfo() { // 获取用户信息 getUserInfo() { // 获取用户信息
......
...@@ -14,11 +14,16 @@ ...@@ -14,11 +14,16 @@
methods: { methods: {
}, },
onReady(){ onLoad(){
//#ifdef MP-WEIXIN uni.showLoading({
title: '加载中...'
})
let _this=this let _this=this
uni.getProvider({
service: 'oauth',
success(proRes){
uni.login({ uni.login({
provider: 'weixin', provider:proRes.provider[0],
success: function (res) { success: function (res) {
if(res.code){ if(res.code){
let data={ let data={
...@@ -29,20 +34,27 @@ ...@@ -29,20 +34,27 @@
if(res.code=='00'){ if(res.code=='00'){
let openid=res.data.openid let openid=res.data.openid
uni.setStorageSync('openid',openid) uni.setStorageSync('openid',openid)
uni.navigateBack({
delta:1
})
}else{ }else{
uni.removeStorageSync('openid') uni.removeStorageSync('openid')
uni.showToast({ uni.showToast({
title:res.message, title:res.message,
icon:"none" icon:"none"
}) })
uni.hideLoading()
} }
}).catch((err)=>{ }).catch((err)=>{
uni.removeStorageSync('openid') uni.removeStorageSync('openid')
uni.hideLoading()
}) })
} }
} }
}) })
//#endif }
})
}, },
} }
</script> </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 = ...@@ -99,10 +99,10 @@ Object.defineProperty(exports, "__esModule", { value: true });exports.default =
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全 //4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
var _default = { var _default = {
onLaunch: function onLaunch() {//初始化完成时触发(全局只触发一次 onLaunch: function onLaunch() {//初始化完成时触发(全局只触发一次
console.log('App Launch');
}, },
onShow: function onShow() { onShow: function onShow() {
console.log('App Show');
}, },
onHide: function onHide() { onHide: function onHide() {
console.log('App Hide'); console.log('App Hide');
......
...@@ -10,6 +10,56 @@ ...@@ -10,6 +10,56 @@
"use strict"; "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;} 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 _toString = Object.prototype.toString;
var hasOwnProperty = Object.prototype.hasOwnProperty; var hasOwnProperty = Object.prototype.hasOwnProperty;
...@@ -940,6 +990,23 @@ var protocols = { // 需要做转换的 API 列表 ...@@ -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: { requestPayment: {
name: 'tradePay', name: 'tradePay',
args: { args: {
...@@ -1992,6 +2059,7 @@ function parseBaseApp(vm, _ref6) ...@@ -1992,6 +2059,7 @@ function parseBaseApp(vm, _ref6)
if (vm.$options.store) { if (vm.$options.store) {
_vue.default.prototype.$store = vm.$options.store; _vue.default.prototype.$store = vm.$options.store;
} }
uniIdMixin(_vue.default);
_vue.default.prototype.mpHost = "mp-alipay"; _vue.default.prototype.mpHost = "mp-alipay";
......
<view class="bottom"><web-view src="https://wx.pangdly.com"></web-view></view> <view hidden="{{!(showBottom)}}" class="bottom"><web-view src="https://wx.pangdly.com"></web-view></view>
\ No newline at end of file \ No newline at end of file
...@@ -205,26 +205,12 @@ var _default = ...@@ -205,26 +205,12 @@ var _default =
{ {
data: function data() { data: function data() {
return { return {
title: '胖丁首页' }; title: '胖丁首页',
showBottom: false //控制底部显示隐藏
};
}, },
onReady: function onReady() { onLoad: function onLoad() {
var _this = this;
...@@ -238,32 +224,16 @@ var _default = ...@@ -238,32 +224,16 @@ var _default =
var _this = this; if (uni.getStorageSync("openid")) {
uni.login({ _this.showBottom = true;
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 { } else {
uni.removeStorageSync('openid'); uni.navigateTo({
uni.showToast({ url: "../login/login" });
title: res.message,
icon: "none" });
} }
}).catch(function (err) {
uni.removeStorageSync('openid');
});
}
} });
},
onReady: function onReady() {
}, },
methods: { methods: {
......
...@@ -128,7 +128,7 @@ __webpack_require__.r(__webpack_exports__); ...@@ -128,7 +128,7 @@ __webpack_require__.r(__webpack_exports__);
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "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 = ...@@ -144,36 +144,49 @@ var _default =
methods: {}, 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; } };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 = ...@@ -99,10 +99,10 @@ Object.defineProperty(exports, "__esModule", { value: true });exports.default =
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全 //4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
var _default = { var _default = {
onLaunch: function onLaunch() {//初始化完成时触发(全局只触发一次 onLaunch: function onLaunch() {//初始化完成时触发(全局只触发一次
console.log('App Launch');
}, },
onShow: function onShow() { onShow: function onShow() {
console.log('App Show');
}, },
onHide: function onHide() { onHide: function onHide() {
console.log('App Hide'); console.log('App Hide');
......
...@@ -10,6 +10,56 @@ ...@@ -10,6 +10,56 @@
"use strict"; "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;} 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 _toString = Object.prototype.toString;
var hasOwnProperty = Object.prototype.hasOwnProperty; var hasOwnProperty = Object.prototype.hasOwnProperty;
...@@ -822,7 +872,7 @@ function initData(vueOptions, context) { ...@@ -822,7 +872,7 @@ function initData(vueOptions, context) {
try { try {
data = data.call(context); // 支持 Vue.prototype 上挂的数据 data = data.call(context); // 支持 Vue.prototype 上挂的数据
} catch (e) { } 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); console.warn('根据 Vue 的 data 函数初始化小程序 data 失败,请尽量确保 data 函数中不访问 vm 对象,否则可能影响首次数据渲染速度。', data);
} }
} }
...@@ -1355,6 +1405,7 @@ function parseBaseApp(vm, _ref3) ...@@ -1355,6 +1405,7 @@ function parseBaseApp(vm, _ref3)
if (vm.$options.store) { if (vm.$options.store) {
_vue.default.prototype.$store = vm.$options.store; _vue.default.prototype.$store = vm.$options.store;
} }
uniIdMixin(_vue.default);
_vue.default.prototype.mpHost = "mp-weixin"; _vue.default.prototype.mpHost = "mp-weixin";
...@@ -7395,7 +7446,7 @@ function type(obj) { ...@@ -7395,7 +7446,7 @@ function type(obj) {
function flushCallbacks$1(vm) { function flushCallbacks$1(vm) {
if (vm.__next_tick_callbacks && vm.__next_tick_callbacks.length) { 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; var mpInstance = vm.$scope;
console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid + console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid +
']:flushCallbacks[' + vm.__next_tick_callbacks.length + ']'); ']:flushCallbacks[' + vm.__next_tick_callbacks.length + ']');
...@@ -7416,14 +7467,14 @@ function nextTick$1(vm, cb) { ...@@ -7416,14 +7467,14 @@ function nextTick$1(vm, cb) {
//1.nextTick 之前 已 setData 且 setData 还未回调完成 //1.nextTick 之前 已 setData 且 setData 还未回调完成
//2.nextTick 之前存在 render watcher //2.nextTick 之前存在 render watcher
if (!vm.__next_tick_pending && !hasRenderWatcher(vm)) { 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; var mpInstance = vm.$scope;
console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid + console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid +
']:nextVueTick'); ']:nextVueTick');
} }
return nextTick(cb, vm) return nextTick(cb, vm)
}else{ }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; var mpInstance$1 = vm.$scope;
console.log('[' + (+new Date) + '][' + (mpInstance$1.is || mpInstance$1.route) + '][' + vm._uid + console.log('[' + (+new Date) + '][' + (mpInstance$1.is || mpInstance$1.route) + '][' + vm._uid +
']:nextMPTick'); ']:nextMPTick');
...@@ -7509,7 +7560,7 @@ var patch = function(oldVnode, vnode) { ...@@ -7509,7 +7560,7 @@ var patch = function(oldVnode, vnode) {
}); });
var diffData = this.$shouldDiffData === false ? data : diff(data, mpData); var diffData = this.$shouldDiffData === false ? data : diff(data, mpData);
if (Object.keys(diffData).length) { 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 + console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + this._uid +
']差量更新', ']差量更新',
JSON.stringify(diffData)); JSON.stringify(diffData));
......
...@@ -205,38 +205,36 @@ var _default = ...@@ -205,38 +205,36 @@ var _default =
{ {
data: function data() { data: function data() {
return { return {
title: '胖丁首页' }; title: '胖丁首页',
showBottom: false //控制底部显示隐藏
};
},
onLoad: function onLoad() {
var _this = this;
uni.checkSession({
success: function success() {
_this.showBottom = true;
}, },
onReady: function onReady() { fail: function fail() {
uni.navigateTo({
url: "../login/login" });
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');
});
}
} }); } });
},
onReady: function onReady() {
}, },
methods: { methods: {
getUserInfo: function getUserInfo() {// 获取用户信息 getUserInfo: function getUserInfo() {// 获取用户信息
......
<view class="bottom"><web-view src="https://wx.pangdly.com"></web-view></view> <view hidden="{{!(showBottom)}}" class="bottom"><web-view src="https://wx.pangdly.com"></web-view></view>
\ No newline at end of file \ No newline at end of file
...@@ -144,11 +144,16 @@ var _default = ...@@ -144,11 +144,16 @@ var _default =
methods: {}, methods: {},
onReady: function onReady() { onLoad: function onLoad() {
uni.showLoading({
title: '加载中...' });
var _this = this; var _this = this;
uni.getProvider({
service: 'oauth',
success: function success(proRes) {
uni.login({ uni.login({
provider: 'weixin', provider: proRes.provider[0],
success: function success(res) { success: function success(res) {
if (res.code) { if (res.code) {
var data = { var data = {
...@@ -159,19 +164,26 @@ var _default = ...@@ -159,19 +164,26 @@ var _default =
if (res.code == '00') { if (res.code == '00') {
var openid = res.data.openid; var openid = res.data.openid;
uni.setStorageSync('openid', openid); uni.setStorageSync('openid', openid);
uni.navigateBack({
delta: 1 });
} else { } else {
uni.removeStorageSync('openid'); uni.removeStorageSync('openid');
uni.showToast({ uni.showToast({
title: res.message, title: res.message,
icon: "none" }); icon: "none" });
uni.hideLoading();
} }
}).catch(function (err) { }).catch(function (err) {
uni.removeStorageSync('openid'); uni.removeStorageSync('openid');
uni.hideLoading();
}); });
} }
} }); } });
} });
} };exports.default = _default; } };exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 1)["default"])) /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 1)["default"]))
......
...@@ -137,12 +137,12 @@ Object.defineProperty(exports, "__esModule", { value: true });exports.default = ...@@ -137,12 +137,12 @@ Object.defineProperty(exports, "__esModule", { value: true });exports.default =
var _default = var _default =
{ {
data: function data() { data: function data() {
return { return {};
order: "" };
}, },
onLoad: function onLoad(option) { onLoad: function onLoad(option) {
this.order = option.order;
}, },
methods: {} };exports.default = _default; methods: {} };exports.default = _default;
......
<view><web-view src="{{'https://wx.pangdly.com/#/paySuccess?order='+order}}"></web-view></view> <view><web-view src="https://wx.pangdly.com/#/paySuccess"></web-view></view>
\ No newline at end of file \ No newline at end of file
...@@ -231,7 +231,6 @@ var _default = ...@@ -231,7 +231,6 @@ var _default =
{ {
data: function data() { data: function data() {
return { return {
orderId: "", //订单id
merchantName: "", //商户名称 merchantName: "", //商户名称
productName: "", //产品名称 productName: "", //产品名称
orderList: "", //订单列表 orderList: "", //订单列表
...@@ -252,7 +251,7 @@ var _default = ...@@ -252,7 +251,7 @@ var _default =
}, },
onLoad: function onLoad(option) {var _this = this; onLoad: function onLoad(option) {var _this = this;
var data = { var data = {
orderId: option.order, //订单Id orderId: option.orderId, //订单Id
userId: uni.getStorageSync("openid"), //用户Id userId: uni.getStorageSync("openid"), //用户Id
payType: 42 //支付类型 payType: 42 //支付类型
}; };
...@@ -301,7 +300,7 @@ var _default = ...@@ -301,7 +300,7 @@ var _default =
paySign: this.paySign, paySign: this.paySign,
success: function success(res) { success: function success(res) {
uni.redirectTo({ uni.redirectTo({
url: 'paySuccess?orderId=123456' }); url: "../paySuccess/paySuccess" });
}, },
fail: function fail(err) { fail: function fail(err) {
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
"libVersion": "", "libVersion": "",
"appid": "wxe678d5240e98a7b8", "appid": "wxe678d5240e98a7b8",
"projectname": "uni-pdtravel", "projectname": "uni-pdtravel",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": { "condition": {
"search": { "search": {
"list": [] "list": []
......
...@@ -11,20 +11,7 @@ ...@@ -11,20 +11,7 @@
"list": [] "list": []
}, },
"miniprogram": { "miniprogram": {
"list": [ "list": []
{
"name": "pages/index/index",
"pathName": "pages/index/index",
"query": "",
"scene": null
},
{
"name": "pages/payment/payment",
"pathName": "pages/payment/payment",
"query": "",
"scene": null
}
]
} }
} }
} }
\ 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