优化H5登录逻辑
This commit is contained in:
@ -61,11 +61,11 @@ export function getArticleDetails(id) {
|
||||
* @returns {*}
|
||||
*/
|
||||
export function getWechatConfig() {
|
||||
// return request.get(
|
||||
// "/wechat/config",
|
||||
// { url: document.location.href },
|
||||
// { login: false }
|
||||
// );
|
||||
return request.get(
|
||||
"/wechat/config",
|
||||
{ url: document.location.href },
|
||||
{ login: false }
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
119
libs/order.js
119
libs/order.js
@ -2,6 +2,8 @@ import { cancelOrder, takeOrder, delOrder, payOrder } from "@/api/order";
|
||||
import dialog from "@/utils/dialog";
|
||||
import { weappPay } from "@/libs/wechat";
|
||||
|
||||
import { _router } from '@/utils'
|
||||
|
||||
export function cancelOrderHandle(orderId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.showModal({
|
||||
@ -70,49 +72,92 @@ export function delOrderHandle(orderId) {
|
||||
});
|
||||
}
|
||||
|
||||
// 使用订单号进行支付
|
||||
export function payOrderHandle(orderId, type, from) {
|
||||
console.log(orderId, type, from, '支付')
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.showLoading({ title: '加载中' })
|
||||
// dialog.loading.open("");
|
||||
payOrder(orderId, type, from)
|
||||
.then(res => {
|
||||
console.log(res)
|
||||
console.log('微信支付参数')
|
||||
const data = res.data;
|
||||
uni.hideLoading()
|
||||
switch (data.status) {
|
||||
case "WECHAT_H5_PAY":
|
||||
location.replace(data.result.jsConfig.mweb_url);
|
||||
reject(data);
|
||||
break;
|
||||
case "ORDER_EXIST":
|
||||
case "EXTEND_ORDER":
|
||||
case "PAY_ERROR":
|
||||
case "PAY_DEFICIENCY":
|
||||
uni.showToast({ title: res.msg, icon: 'none', duration: 2000 });
|
||||
reject(data);
|
||||
break;
|
||||
case "SUCCESS":
|
||||
uni.showToast({ title: res.msg, icon: 'none', duration: 2000 });
|
||||
resolve(data);
|
||||
break;
|
||||
case "WECHAT_PAY":
|
||||
weappPay(data.result.jsConfig).then(res => {
|
||||
resolve(data);
|
||||
});
|
||||
break;
|
||||
case "WECHAT_APP_PAY":
|
||||
weappPay(data.result.jsConfig).then(res => {
|
||||
resolve(data);
|
||||
});
|
||||
break;
|
||||
}
|
||||
handleOrderPayResults(res.data)
|
||||
})
|
||||
.catch(err => {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '订单支付失败', icon: 'none', duration: 2000
|
||||
});
|
||||
dialog.loading.close();
|
||||
dialog.toast({ mes: err.msg || "订单支付失败" });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 处理调用支付接口的逻辑
|
||||
// @type create(创建订单)||pay(支付订单)
|
||||
export function handleOrderPayResults(data, type) {
|
||||
switch (data.status) {
|
||||
// 订单号已存在
|
||||
case "ORDER_EXIST":
|
||||
// 取消支付
|
||||
case "EXTEND_ORDER":
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
goOrderDetails(data.result.orderId, type)
|
||||
break;
|
||||
case "PAY_DEFICIENCY":
|
||||
break;
|
||||
// 支付出错
|
||||
case "PAY_ERROR":
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
goOrderDetails(data.result.orderId, type)
|
||||
break;
|
||||
// 未传递支付环境
|
||||
case "SUCCESS":
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
goOrderDetails(data.result.orderId, type)
|
||||
break;
|
||||
// H5支付
|
||||
case "WECHAT_H5_PAY":
|
||||
goOrderDetails(data.result.orderId, type)
|
||||
console.log(data)
|
||||
setTimeout(() => {
|
||||
// #ifdef H5
|
||||
// "https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx15171343713577e9f3a418b0865ef90000&package=2547890641"
|
||||
// location.href = data.result.jsConfig.mweb_url;
|
||||
// #endif
|
||||
}, 100);
|
||||
break;
|
||||
// 小程序支付
|
||||
case "WECHAT_PAY":
|
||||
weappPay(data.result.jsConfig).finally(() => {
|
||||
goOrderDetails(data.result.orderId, type)
|
||||
});
|
||||
break;
|
||||
// APP支付
|
||||
case "WECHAT_APP_PAY":
|
||||
weappPay(data.result.jsConfig).finally(() => {
|
||||
goOrderDetails(data.result.orderId, type)
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function goOrderDetails(id, type) {
|
||||
// 创建订单时跳转到详情
|
||||
if (type == 'create') {
|
||||
console.log(_router)
|
||||
_router.replace({
|
||||
path: "/pages/order/OrderDetails/index",
|
||||
query: {
|
||||
id
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
285
libs/wechat.js
285
libs/wechat.js
@ -41,3 +41,288 @@ export const weappPay = (option) => {
|
||||
// })
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
import WechatJSSDK from "wechat-jssdk/dist/client.umd";
|
||||
import { getWechatConfig, wechatAuth } from "@/api/public";
|
||||
import { parseQuery } from "@/utils";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import store from "@/store";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
const STATE_KEY = "wx_authorize_state";
|
||||
const WX_AUTH = "wx_auth";
|
||||
const BACK_URL = "login_back_url";
|
||||
const LOGINTYPE = "loginType";
|
||||
let instance;
|
||||
let wechatObj;
|
||||
|
||||
export function wechat() {
|
||||
console.log('初始化微信配置')
|
||||
return new Promise((resolve, reject) => {
|
||||
if (instance) return resolve(instance);
|
||||
getWechatConfig()
|
||||
.then(res => {
|
||||
const _wx = WechatJSSDK(res.data);
|
||||
console.log(_wx)
|
||||
wechatObj = _wx;
|
||||
_wx
|
||||
.initialize()
|
||||
.then(() => {
|
||||
instance = _wx.wx;
|
||||
instance.initConfig = res.data;
|
||||
resolve(instance);
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function clearAuthStatus() {
|
||||
cookie.remove(WX_AUTH);
|
||||
cookie.remove(STATE_KEY);
|
||||
}
|
||||
|
||||
export function oAuth() {
|
||||
console.log('处理微信授权')
|
||||
return new Promise((resolve, reject) => {
|
||||
if (cookie.has(WX_AUTH) && store.state.app.token) {
|
||||
reject()
|
||||
return;
|
||||
}
|
||||
const { code } = parseQuery();
|
||||
if (!code) {
|
||||
toAuth();
|
||||
return
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
export function auth(code) {
|
||||
console.log('获取微信授权')
|
||||
return new Promise((resolve, reject) => {
|
||||
let loginType = cookie.get(LOGINTYPE);
|
||||
wechatAuth(code, parseInt(cookie.get("spread")), loginType)
|
||||
.then(({ data }) => {
|
||||
const expires_time = dayjs(data.expires_time);
|
||||
const newTime = Math.round(new Date() / 1000);
|
||||
store.commit("LOGIN", data.token, expires_time - newTime);
|
||||
cookie.set(WX_AUTH, code, expires_time);
|
||||
cookie.remove(STATE_KEY);
|
||||
loginType && cookie.remove("loginType");
|
||||
resolve();
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
export function toAuth() {
|
||||
wechat().then(wx => {
|
||||
location.href = getAuthUrl(wx.initConfig.appId);
|
||||
});
|
||||
}
|
||||
|
||||
function getAuthUrl(appId) {
|
||||
const redirect_uri = encodeURIComponent(
|
||||
`${location.origin}/auth/` +
|
||||
encodeURIComponent(
|
||||
encodeURIComponent(
|
||||
cookie.has(BACK_URL)
|
||||
? cookie.get(BACK_URL)
|
||||
: location.pathname + location.search
|
||||
)
|
||||
)
|
||||
);
|
||||
cookie.remove(BACK_URL);
|
||||
const state = encodeURIComponent(
|
||||
("" + Math.random()).split(".")[1] + "authorizestate"
|
||||
);
|
||||
cookie.set(STATE_KEY, state);
|
||||
return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect`;
|
||||
}
|
||||
|
||||
function toPromise(fn, config = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fn({
|
||||
...config,
|
||||
success(res) {
|
||||
resolve(res);
|
||||
},
|
||||
fail(err) {
|
||||
reject(err);
|
||||
},
|
||||
complete(err) {
|
||||
reject(err);
|
||||
},
|
||||
cancel(err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function pay(config) {
|
||||
return toPromise(instance.chooseWXPay, config);
|
||||
}
|
||||
|
||||
export function openAddress() {
|
||||
return new Promise((resolve, reject) => {
|
||||
wechatEvevt("openAddress", {})
|
||||
.then(res => {
|
||||
resolve(res);
|
||||
})
|
||||
.catch(res => {
|
||||
if (res.is_ready) {
|
||||
res.wx.openAddress({
|
||||
fail(res) {
|
||||
reject(res);
|
||||
},
|
||||
success(res) {
|
||||
resolve(res);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
reject(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function openShareAll(config) {
|
||||
config || {};
|
||||
config.type = config.type == undefined ? "link" : config.type;
|
||||
return new Promise(resolve => {
|
||||
getWechatConfig().then(res => {
|
||||
wechatObj.signSignature({
|
||||
nonceStr: res.data.nonceStr,
|
||||
signature: res.data.signature,
|
||||
timestamp: res.data.timestamp
|
||||
});
|
||||
instance = wechatObj.getOriginalWx();
|
||||
instance.ready(() => {
|
||||
instance.updateAppMessageShareData(config);
|
||||
instance.updateTimelineShareData(config);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function openShareAppMessage(config) {
|
||||
instance.updateAppMessageShareData(config);
|
||||
instance.onMenuShareAppMessage && instance.onMenuShareAppMessage(config);
|
||||
}
|
||||
|
||||
export function openShareTimeline(config) {
|
||||
instance.updateTimelineShareData(config);
|
||||
instance.onMenuShareTimeline && instance.onMenuShareTimeline(config);
|
||||
}
|
||||
|
||||
export function wechatEvevt(name, config) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let wx;
|
||||
let configDefault = {
|
||||
fail(res) {
|
||||
console.log(res);
|
||||
if (wx) return reject({ is_ready: true, wx: wx });
|
||||
getWechatConfig().then(res => {
|
||||
wechatObj.signSignature({
|
||||
nonceStr: res.data.nonceStr,
|
||||
signature: res.data.signature,
|
||||
timestamp: res.data.timestamp
|
||||
});
|
||||
wx = wechatObj.getOriginalWx();
|
||||
reject({ is_ready: true, wx: wx });
|
||||
});
|
||||
},
|
||||
success(res) {
|
||||
resolve(res);
|
||||
}
|
||||
};
|
||||
Object.assign(configDefault, config);
|
||||
if (typeof instance !== "undefined") {
|
||||
instance.ready(() => {
|
||||
if (typeof name === "object") {
|
||||
name.forEach(item => {
|
||||
instance[item] && instance[item](configDefault);
|
||||
});
|
||||
} else instance[name] && instance[name](configDefault);
|
||||
});
|
||||
} else {
|
||||
getWechatConfig().then(res => {
|
||||
const _wx = WechatJSSDK(res.data);
|
||||
_wx.initialize().then(() => {
|
||||
instance = _wx.getOriginalWx();
|
||||
instance.ready(() => {
|
||||
if (typeof name === "object") {
|
||||
name.forEach(item => {
|
||||
instance[item] && instance[item](configDefault);
|
||||
});
|
||||
} else instance[name] && instance[name](configDefault);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function ready() {
|
||||
return new Promise(resolve => {
|
||||
if (typeof instance !== "undefined") {
|
||||
instance.ready(() => {
|
||||
resolve(instance);
|
||||
});
|
||||
} else {
|
||||
getWechatConfig().then(res => {
|
||||
const _wx = WechatJSSDK(res.data);
|
||||
_wx.initialize().then(() => {
|
||||
instance = _wx.wx;
|
||||
instance.ready(() => {
|
||||
resolve(instance);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function wxShowLocation() {
|
||||
return new Promise(() => {
|
||||
wechatEvevt("getLocation", { type: "wgs84" })
|
||||
.then(res => {
|
||||
let latitude = res.latitude; // 纬度
|
||||
let longitude = res.longitude; // 经度
|
||||
cookie.set(LATITUDE, latitude);
|
||||
cookie.set(LONGITUDE, longitude);
|
||||
})
|
||||
.catch(res => {
|
||||
if (res.is_ready) {
|
||||
res.wx.getLocation({
|
||||
success(res) {
|
||||
let latitude = res.latitude; // 纬度
|
||||
let longitude = res.longitude; // 经度
|
||||
cookie.set(LATITUDE, latitude);
|
||||
cookie.set(LONGITUDE, longitude);
|
||||
},
|
||||
cancel() {
|
||||
cookie.remove(LATITUDE);
|
||||
cookie.remove(LONGITUDE);
|
||||
this.$dialog.error("取消获取位置");
|
||||
},
|
||||
fail() {
|
||||
cookie.remove(LATITUDE);
|
||||
cookie.remove(LONGITUDE);
|
||||
this.$dialog.error("授权失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
26
main.js
26
main.js
@ -15,6 +15,12 @@ import cookie from "@/utils/store/cookie";
|
||||
// import "@/assets/css/reset.less";
|
||||
// import "@/assets/css/style.less";
|
||||
|
||||
// // 引入微信jssdk
|
||||
// var jweixin = require('jweixin-module')
|
||||
// jweixin.ready(function(){
|
||||
// // TODO
|
||||
// });
|
||||
|
||||
import {
|
||||
parseRoute,
|
||||
_router
|
||||
@ -27,7 +33,7 @@ import {
|
||||
Vue.config.productionTip = false;
|
||||
Vue.config.devtools = process.env.NODE_ENV !== "production";
|
||||
|
||||
Vue.prototype.$validator = function(rule) {
|
||||
Vue.prototype.$validator = function (rule) {
|
||||
return new schema(rule);
|
||||
};
|
||||
|
||||
@ -77,21 +83,31 @@ Vue.prototype.$VUE_APP_API_URL = VUE_APP_API_URL
|
||||
|
||||
// #ifdef H5
|
||||
// H5编译的代码
|
||||
Vue.prototype.$deviceType = 'h5'
|
||||
store.commit('updateDevicetype','h5')
|
||||
|
||||
import { wechat, oAuth } from '@/libs/wechat'
|
||||
import { isWeixin } from '@/utils'
|
||||
// 判断是否是微信浏览器
|
||||
if (isWeixin()) {
|
||||
Vue.prototype.$deviceType = 'weixin'
|
||||
store.commit('updateDevicetype', 'weixin')
|
||||
} else {
|
||||
Vue.prototype.$deviceType = 'weixinh5'
|
||||
store.commit('updateDevicetype', 'weixinh5')
|
||||
}
|
||||
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
// App平台编译的代码
|
||||
Vue.prototype.$deviceType = 'app'
|
||||
store.commit('updateDevicetype','app')
|
||||
store.commit('updateDevicetype', 'app')
|
||||
Vue.prototype.$platform = uni.getSystemInfoSync().platform
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
// 微信小程序编译的代码
|
||||
Vue.prototype.$deviceType = 'routine'
|
||||
store.commit('updateDevicetype','routine')
|
||||
store.commit('updateDevicetype', 'routine')
|
||||
// #endif
|
||||
|
||||
// !!! ps 不建议在 template 中使用 $deviceType 去判断当前环境,很有可能出现 $deviceType 为 undefined 导致判断出错的问题,可以在 script 模块中正常使用
|
||||
|
@ -128,9 +128,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
/* 快应用特有相关 */
|
||||
"quickapp" : {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
"appid" : "wx604d2ea4702620d2",
|
||||
"setting" : {
|
||||
@ -151,5 +149,11 @@
|
||||
},
|
||||
"mp-toutiao" : {
|
||||
"usingComponents" : true
|
||||
},
|
||||
"h5" : {
|
||||
"title" : "yshop",
|
||||
"devServer": {
|
||||
"disableHostCheck": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
392
package-lock.json
generated
392
package-lock.json
generated
@ -4,6 +4,19 @@
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@sindresorhus/is": {
|
||||
"version": "0.14.0",
|
||||
"resolved": "https://registry.npm.taobao.org/@sindresorhus/is/download/@sindresorhus/is-0.14.0.tgz?cache=0&sync_timestamp=1595758234190&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40sindresorhus%2Fis%2Fdownload%2F%40sindresorhus%2Fis-0.14.0.tgz",
|
||||
"integrity": "sha1-n7OjzzEyMoFR81PeRjLgHlIQK+o="
|
||||
},
|
||||
"@szmarczak/http-timer": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npm.taobao.org/@szmarczak/http-timer/download/@szmarczak/http-timer-1.1.2.tgz",
|
||||
"integrity": "sha1-sWZeLEYaLNkvTBu/UNVFTeDUtCE=",
|
||||
"requires": {
|
||||
"defer-to-connect": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"animate.css": {
|
||||
"version": "3.7.2",
|
||||
"resolved": "https://registry.npm.taobao.org/animate.css/download/animate.css-3.7.2.tgz",
|
||||
@ -14,15 +27,394 @@
|
||||
"resolved": "https://registry.npm.taobao.org/async-validator/download/async-validator-3.2.4.tgz",
|
||||
"integrity": "sha1-Tnc6HQ10EBa0VbeZW0aaR8zg2+A="
|
||||
},
|
||||
"bluebird": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npm.taobao.org/bluebird/download/bluebird-3.5.1.tgz",
|
||||
"integrity": "sha1-2VUfnemPH82h5oPRfukaBgLuLrk="
|
||||
},
|
||||
"bson": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npm.taobao.org/bson/download/bson-1.1.5.tgz?cache=0&sync_timestamp=1597069108497&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbson%2Fdownload%2Fbson-1.1.5.tgz",
|
||||
"integrity": "sha1-Kqrpj832dQwISLDLod3sPHMGCjQ="
|
||||
},
|
||||
"cacheable-request": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npm.taobao.org/cacheable-request/download/cacheable-request-6.1.0.tgz",
|
||||
"integrity": "sha1-IP+4vRYrpL4R6VZ9gj22UQUsqRI=",
|
||||
"requires": {
|
||||
"clone-response": "^1.0.2",
|
||||
"get-stream": "^5.1.0",
|
||||
"http-cache-semantics": "^4.0.0",
|
||||
"keyv": "^3.0.0",
|
||||
"lowercase-keys": "^2.0.0",
|
||||
"normalize-url": "^4.1.0",
|
||||
"responselike": "^1.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"get-stream": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npm.taobao.org/get-stream/download/get-stream-5.2.0.tgz?cache=0&sync_timestamp=1597056464385&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fget-stream%2Fdownload%2Fget-stream-5.2.0.tgz",
|
||||
"integrity": "sha1-SWaheV7lrOZecGxLe+txJX1uItM=",
|
||||
"requires": {
|
||||
"pump": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"lowercase-keys": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npm.taobao.org/lowercase-keys/download/lowercase-keys-2.0.0.tgz",
|
||||
"integrity": "sha1-JgPni3tLAAbLyi+8yKMgJVislHk="
|
||||
}
|
||||
}
|
||||
},
|
||||
"clone-response": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npm.taobao.org/clone-response/download/clone-response-1.0.2.tgz",
|
||||
"integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=",
|
||||
"requires": {
|
||||
"mimic-response": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"date-fns": {
|
||||
"version": "2.9.0",
|
||||
"resolved": "https://registry.npm.taobao.org/date-fns/download/date-fns-2.9.0.tgz?cache=0&sync_timestamp=1594999069362&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdate-fns%2Fdownload%2Fdate-fns-2.9.0.tgz",
|
||||
"integrity": "sha1-0LF1pcN+1fF7l+InK7wfpa7Gd9I="
|
||||
},
|
||||
"dayjs": {
|
||||
"version": "1.8.22",
|
||||
"resolved": "https://registry.npm.taobao.org/dayjs/download/dayjs-1.8.22.tgz",
|
||||
"integrity": "sha1-XoNdd2s3PiFmeL6NEsM22nGiWpw="
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npm.taobao.org/debug/download/debug-4.1.1.tgz",
|
||||
"integrity": "sha1-O3ImAlUQnGtYnO4FDx1RYTlmR5E=",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"decompress-response": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npm.taobao.org/decompress-response/download/decompress-response-3.3.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdecompress-response%2Fdownload%2Fdecompress-response-3.3.0.tgz",
|
||||
"integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=",
|
||||
"requires": {
|
||||
"mimic-response": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"defer-to-connect": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npm.taobao.org/defer-to-connect/download/defer-to-connect-1.1.3.tgz?cache=0&sync_timestamp=1580234632952&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdefer-to-connect%2Fdownload%2Fdefer-to-connect-1.1.3.tgz",
|
||||
"integrity": "sha1-MxrgUMCNz3ifjIOnuB8O2U9KxZE="
|
||||
},
|
||||
"duplexer3": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npm.taobao.org/duplexer3/download/duplexer3-0.1.4.tgz",
|
||||
"integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI="
|
||||
},
|
||||
"end-of-stream": {
|
||||
"version": "1.4.4",
|
||||
"resolved": "https://registry.npm.taobao.org/end-of-stream/download/end-of-stream-1.4.4.tgz",
|
||||
"integrity": "sha1-WuZKX0UFe682JuwU2gyl5LJDHrA=",
|
||||
"requires": {
|
||||
"once": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"get-stream": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npm.taobao.org/get-stream/download/get-stream-4.1.0.tgz?cache=0&sync_timestamp=1597056464385&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fget-stream%2Fdownload%2Fget-stream-4.1.0.tgz",
|
||||
"integrity": "sha1-wbJVV189wh1Zv8ec09K0axw6VLU=",
|
||||
"requires": {
|
||||
"pump": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"got": {
|
||||
"version": "9.6.0",
|
||||
"resolved": "https://registry.npm.taobao.org/got/download/got-9.6.0.tgz?cache=0&sync_timestamp=1596795574468&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fgot%2Fdownload%2Fgot-9.6.0.tgz",
|
||||
"integrity": "sha1-7fRefWf5lUVwXeH3u+7rEhdl7YU=",
|
||||
"requires": {
|
||||
"@sindresorhus/is": "^0.14.0",
|
||||
"@szmarczak/http-timer": "^1.1.2",
|
||||
"cacheable-request": "^6.0.0",
|
||||
"decompress-response": "^3.3.0",
|
||||
"duplexer3": "^0.1.4",
|
||||
"get-stream": "^4.1.0",
|
||||
"lowercase-keys": "^1.0.1",
|
||||
"mimic-response": "^1.0.1",
|
||||
"p-cancelable": "^1.0.0",
|
||||
"to-readable-stream": "^1.0.0",
|
||||
"url-parse-lax": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"http-cache-semantics": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npm.taobao.org/http-cache-semantics/download/http-cache-semantics-4.1.0.tgz?cache=0&sync_timestamp=1583108120479&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fhttp-cache-semantics%2Fdownload%2Fhttp-cache-semantics-4.1.0.tgz",
|
||||
"integrity": "sha1-SekcXL82yblLz81xwj1SSex045A="
|
||||
},
|
||||
"json-buffer": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npm.taobao.org/json-buffer/download/json-buffer-3.0.0.tgz",
|
||||
"integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg="
|
||||
},
|
||||
"jweixin-module": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npm.taobao.org/jweixin-module/download/jweixin-module-1.6.0.tgz",
|
||||
"integrity": "sha1-Sn6mFAg+PJw/SeL9wruILPpY380="
|
||||
},
|
||||
"kareem": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npm.taobao.org/kareem/download/kareem-2.3.1.tgz",
|
||||
"integrity": "sha1-3vEtnJQQF/q/sA+HOvlenJnhvoc="
|
||||
},
|
||||
"keyv": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npm.taobao.org/keyv/download/keyv-3.1.0.tgz",
|
||||
"integrity": "sha1-7MIoSG9pmR5J6UdkhaW+Ho/FxNk=",
|
||||
"requires": {
|
||||
"json-buffer": "3.0.0"
|
||||
}
|
||||
},
|
||||
"lodash.isempty": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npm.taobao.org/lodash.isempty/download/lodash.isempty-4.4.0.tgz",
|
||||
"integrity": "sha1-b4bL7di+TsmHvpqvM8loTbGzHn4="
|
||||
},
|
||||
"lowercase-keys": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npm.taobao.org/lowercase-keys/download/lowercase-keys-1.0.1.tgz",
|
||||
"integrity": "sha1-b54wtHCE2XGnyCD/FabFFnt0wm8="
|
||||
},
|
||||
"memory-pager": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npm.taobao.org/memory-pager/download/memory-pager-1.5.0.tgz",
|
||||
"integrity": "sha1-2HUWVdItOEaCdByXLyw9bfo+ZrU=",
|
||||
"optional": true
|
||||
},
|
||||
"mimic-response": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npm.taobao.org/mimic-response/download/mimic-response-1.0.1.tgz?cache=0&sync_timestamp=1589481629775&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmimic-response%2Fdownload%2Fmimic-response-1.0.1.tgz",
|
||||
"integrity": "sha1-SSNTiHju9CBjy4o+OweYeBSHqxs="
|
||||
},
|
||||
"mongodb": {
|
||||
"version": "3.4.1",
|
||||
"resolved": "https://registry.npm.taobao.org/mongodb/download/mongodb-3.4.1.tgz",
|
||||
"integrity": "sha1-DRXlfg6g/IW3pPuSkbN0wucWUtw=",
|
||||
"requires": {
|
||||
"bson": "^1.1.1",
|
||||
"require_optional": "^1.0.1",
|
||||
"safe-buffer": "^5.1.2",
|
||||
"saslprep": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"mongoose": {
|
||||
"version": "5.8.9",
|
||||
"resolved": "https://registry.npm.taobao.org/mongoose/download/mongoose-5.8.9.tgz?cache=0&sync_timestamp=1597421711994&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmongoose%2Fdownload%2Fmongoose-5.8.9.tgz",
|
||||
"integrity": "sha1-YWrp30zX9B99LXfQN62UeESFvXQ=",
|
||||
"requires": {
|
||||
"bson": "~1.1.1",
|
||||
"kareem": "2.3.1",
|
||||
"mongodb": "3.4.1",
|
||||
"mongoose-legacy-pluralize": "1.0.2",
|
||||
"mpath": "0.6.0",
|
||||
"mquery": "3.2.2",
|
||||
"ms": "2.1.2",
|
||||
"regexp-clone": "1.0.0",
|
||||
"safe-buffer": "5.1.2",
|
||||
"sift": "7.0.1",
|
||||
"sliced": "1.0.1"
|
||||
}
|
||||
},
|
||||
"mongoose-legacy-pluralize": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npm.taobao.org/mongoose-legacy-pluralize/download/mongoose-legacy-pluralize-1.0.2.tgz",
|
||||
"integrity": "sha1-O6n5H6UHtRhtOZ+0CFS/8Y+1Y+Q="
|
||||
},
|
||||
"mpath": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npm.taobao.org/mpath/download/mpath-0.6.0.tgz",
|
||||
"integrity": "sha1-qpIgKfyk8PZB82DnTFwbakxHB44="
|
||||
},
|
||||
"mquery": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npm.taobao.org/mquery/download/mquery-3.2.2.tgz",
|
||||
"integrity": "sha1-4Tg6OVGFLOI+N/YZqbNQ8fs2ZOc=",
|
||||
"requires": {
|
||||
"bluebird": "3.5.1",
|
||||
"debug": "3.1.0",
|
||||
"regexp-clone": "^1.0.0",
|
||||
"safe-buffer": "5.1.2",
|
||||
"sliced": "1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz",
|
||||
"integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
}
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npm.taobao.org/ms/download/ms-2.1.2.tgz",
|
||||
"integrity": "sha1-0J0fNXtEP0kzgqjrPM0YOHKuYAk="
|
||||
},
|
||||
"normalize-url": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npm.taobao.org/normalize-url/download/normalize-url-4.5.0.tgz?cache=0&sync_timestamp=1596373090568&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnormalize-url%2Fdownload%2Fnormalize-url-4.5.0.tgz",
|
||||
"integrity": "sha1-RTNUCH5sqWlXvY9br3U/WYIUISk="
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npm.taobao.org/once/download/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"p-cancelable": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npm.taobao.org/p-cancelable/download/p-cancelable-1.1.0.tgz",
|
||||
"integrity": "sha1-0HjRWjr0CSIMiG8dmgyi5EGrJsw="
|
||||
},
|
||||
"prepend-http": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npm.taobao.org/prepend-http/download/prepend-http-2.0.0.tgz",
|
||||
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc="
|
||||
},
|
||||
"pump": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npm.taobao.org/pump/download/pump-3.0.0.tgz",
|
||||
"integrity": "sha1-tKIRaBW94vTh6mAjVOjHVWUQemQ=",
|
||||
"requires": {
|
||||
"end-of-stream": "^1.1.0",
|
||||
"once": "^1.3.1"
|
||||
}
|
||||
},
|
||||
"regexp-clone": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npm.taobao.org/regexp-clone/download/regexp-clone-1.0.0.tgz",
|
||||
"integrity": "sha1-Ii25Z2IydwViYLmSYmNUoEzpv2M="
|
||||
},
|
||||
"require_optional": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npm.taobao.org/require_optional/download/require_optional-1.0.1.tgz",
|
||||
"integrity": "sha1-TPNaQkf2TKPfjC7yCMxJSxyo/C4=",
|
||||
"requires": {
|
||||
"resolve-from": "^2.0.0",
|
||||
"semver": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"resolve-from": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npm.taobao.org/resolve-from/download/resolve-from-2.0.0.tgz",
|
||||
"integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c="
|
||||
},
|
||||
"responselike": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npm.taobao.org/responselike/download/responselike-1.0.2.tgz?cache=0&sync_timestamp=1570573217730&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fresponselike%2Fdownload%2Fresponselike-1.0.2.tgz",
|
||||
"integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=",
|
||||
"requires": {
|
||||
"lowercase-keys": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.1.2.tgz?cache=0&sync_timestamp=1589129010497&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsafe-buffer%2Fdownload%2Fsafe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha1-mR7GnSluAxN0fVm9/St0XDX4go0="
|
||||
},
|
||||
"saslprep": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npm.taobao.org/saslprep/download/saslprep-1.0.3.tgz",
|
||||
"integrity": "sha1-TAL5RrVs9UKX40e6EJPnrKxM8iY=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"sparse-bitfield": "^3.0.3"
|
||||
}
|
||||
},
|
||||
"sax": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npm.taobao.org/sax/download/sax-1.2.4.tgz",
|
||||
"integrity": "sha1-KBYjTiN4vdxOU1T6tcqold9xANk="
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npm.taobao.org/semver/download/semver-5.7.1.tgz?cache=0&sync_timestamp=1586886301819&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsemver%2Fdownload%2Fsemver-5.7.1.tgz",
|
||||
"integrity": "sha1-qVT5Ma66UI0we78Gnv8MAclhFvc="
|
||||
},
|
||||
"sift": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npm.taobao.org/sift/download/sift-7.0.1.tgz?cache=0&sync_timestamp=1594916082498&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsift%2Fdownload%2Fsift-7.0.1.tgz",
|
||||
"integrity": "sha1-R9YsULFZ0xbxNy+LU/nBDNIaSwg="
|
||||
},
|
||||
"sliced": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npm.taobao.org/sliced/download/sliced-1.0.1.tgz",
|
||||
"integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E="
|
||||
},
|
||||
"sparse-bitfield": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npm.taobao.org/sparse-bitfield/download/sparse-bitfield-3.0.3.tgz",
|
||||
"integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"memory-pager": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"to-readable-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npm.taobao.org/to-readable-stream/download/to-readable-stream-1.0.0.tgz",
|
||||
"integrity": "sha1-zgqgwvPfat+FLvtASng+d8BHV3E="
|
||||
},
|
||||
"url-parse-lax": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npm.taobao.org/url-parse-lax/download/url-parse-lax-3.0.0.tgz",
|
||||
"integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=",
|
||||
"requires": {
|
||||
"prepend-http": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"vue-ydui": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npm.taobao.org/vue-ydui/download/vue-ydui-1.2.6.tgz",
|
||||
"integrity": "sha1-GQZItGcjkXAEpMJKe+/TzWnWQ1U="
|
||||
},
|
||||
"wechat-jssdk": {
|
||||
"version": "5.0.4",
|
||||
"resolved": "https://registry.npm.taobao.org/wechat-jssdk/download/wechat-jssdk-5.0.4.tgz",
|
||||
"integrity": "sha1-QZ1TAjuEzAfIkNM+3c1XkVUcY+c=",
|
||||
"requires": {
|
||||
"date-fns": "2.9.0",
|
||||
"debug": "4.1.1",
|
||||
"got": "9.6.0",
|
||||
"lodash.isempty": "4.4.0",
|
||||
"mongoose": "5.8.9",
|
||||
"xml2js": "0.4.23"
|
||||
}
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npm.taobao.org/wrappy/download/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
},
|
||||
"xml2js": {
|
||||
"version": "0.4.23",
|
||||
"resolved": "https://registry.npm.taobao.org/xml2js/download/xml2js-0.4.23.tgz",
|
||||
"integrity": "sha1-oMaVFnUkIesqx1juTUzPWIQ+rGY=",
|
||||
"requires": {
|
||||
"sax": ">=0.6.0",
|
||||
"xmlbuilder": "~11.0.0"
|
||||
}
|
||||
},
|
||||
"xmlbuilder": {
|
||||
"version": "11.0.1",
|
||||
"resolved": "https://registry.npm.taobao.org/xmlbuilder/download/xmlbuilder-11.0.1.tgz?cache=0&sync_timestamp=1586386177211&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fxmlbuilder%2Fdownload%2Fxmlbuilder-11.0.1.tgz",
|
||||
"integrity": "sha1-vpuuHIoEbnazESdyY0fQrXACvrM="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@
|
||||
"animate.css": "^3.7.2",
|
||||
"async-validator": "^3.2.4",
|
||||
"dayjs": "^1.8.22",
|
||||
"vue-ydui": "^1.2.6"
|
||||
"jweixin-module": "^1.6.0",
|
||||
"vue-ydui": "^1.2.6",
|
||||
"wechat-jssdk": "^5.0.4"
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view v-if="!token">
|
||||
<!-- 小程序 -->
|
||||
<view v-if="$deviceType == 'routine'">
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view>
|
||||
<view class="getUserInfo">
|
||||
<text>您还未允许微信登录授权,请点击下方按钮允许微信授权登录。</text>
|
||||
<button type="primary" open-type="getUserInfo" @getuserinfo="getUserInfo">允许微信登录授权</button>
|
||||
@ -10,21 +10,21 @@
|
||||
<button @click="back">取消微信登录授权</button>
|
||||
</view>
|
||||
</view>
|
||||
<!-- app -->
|
||||
<view v-if="$deviceType == 'app'">
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<view>
|
||||
<view class="getUserInfo">
|
||||
<text>请先登录</text>
|
||||
<button type="primary" @click="this.toLogin">去登录</button>
|
||||
<button type="primary" @tap="toLogin">去登录</button>
|
||||
</view>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState, mapMutations, mapActions } from "vuex";
|
||||
// 组件
|
||||
// import request from "@//api/request";
|
||||
import { wxappAuth, getUser } from "@/api/user";
|
||||
import dayjs from "dayjs";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
@ -33,11 +33,11 @@ import { login, authorize } from "@/utils";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
authorize: false
|
||||
authorize: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(["isAuthorization", "$deviceType", "token"])
|
||||
...mapState(["isAuthorization", "$deviceType", "token"]),
|
||||
},
|
||||
onShow() {
|
||||
// // 先校验用户是否授权,如果没有授权,显示授权按钮
|
||||
@ -52,12 +52,17 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["changeAuthorization", "setUserInfo"]),
|
||||
...mapMutations(["updateAuthorizationPage",]),
|
||||
|
||||
...mapMutations(["updateAuthorizationPage"]),
|
||||
toLogin() {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/user/Login/index",
|
||||
query: {},
|
||||
});
|
||||
},
|
||||
back() {
|
||||
this.$yrouter.switchTab({
|
||||
path: "/pages/home/index",
|
||||
query: {}
|
||||
query: {},
|
||||
});
|
||||
},
|
||||
getUserInfo(data) {
|
||||
@ -65,36 +70,28 @@ export default {
|
||||
uni.showToast({
|
||||
title: "取消授权",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
duration: 2000,
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
title: "登录中"
|
||||
title: "登录中",
|
||||
});
|
||||
login()
|
||||
.then(res => {
|
||||
.then((res) => {
|
||||
this.$yrouter.replace({ path: cookie.get("redirect") });
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
uni.showToast({
|
||||
title: error,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
duration: 2000,
|
||||
});
|
||||
});
|
||||
},
|
||||
toLogin() {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/user/Login/index",
|
||||
query: {}
|
||||
});
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
}
|
||||
mounted() {},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -10,15 +10,6 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="fixed-header-box"></view>
|
||||
|
||||
|
||||
|
||||
|
||||
<button @click="testTemplate">测试模板消息</button>
|
||||
|
||||
|
||||
|
||||
|
||||
<view class="slider-banner banner">
|
||||
<swiper indicatorDots="true" v-if="banner.length > 0" autoplay circular>
|
||||
<block v-for="(item, bannerIndex) in banner" :key="bannerIndex">
|
||||
@ -60,7 +51,7 @@
|
||||
</view>
|
||||
</view> -->
|
||||
<!-- <view class="wrapper hot" v-if="likeInfo.length > 0"> -->
|
||||
<uni-notice-bar scrollable="true" @click="goRoll(singNew)" single="true" speed="10" showIcon="true" :text="singNew.info"></uni-notice-bar>
|
||||
<uni-notice-bar scrollable="true" @click="goRoll(singNew)" single="true" :speed="10" showIcon="true" :text="singNew.info"></uni-notice-bar>
|
||||
<view class="wrapper hot" v-if="bastList.length > 0">
|
||||
<image class="bg" src="../../static/images/index-bg.png" mode="widthFix"></image>
|
||||
<view class="title no-border acea-row row-between-wrapper">
|
||||
@ -288,14 +279,6 @@
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["getLocation"]),
|
||||
testTemplate() {
|
||||
console.log('测试')
|
||||
// 调用订阅
|
||||
wx.requestSubscribeMessage({
|
||||
tmplIds: [''],
|
||||
success(res) {}
|
||||
})
|
||||
},
|
||||
goRoll(item) {
|
||||
if (item.uniapp_url) {
|
||||
this.$yrouter.push(item.uniapp_url)
|
||||
|
@ -310,8 +310,9 @@ import CouponListWindow from "@/components/CouponListWindow";
|
||||
import AddressWindow from "@/components/AddressWindow";
|
||||
import { postOrderConfirm, postOrderComputed, createOrder } from "@/api/order";
|
||||
import { mapGetters } from "vuex";
|
||||
import { handleOrderPayResults } from "@/libs/order";
|
||||
import { weappPay } from "@/libs/wechat";
|
||||
import { isWeixin } from "@/utils";
|
||||
import { isWeixin, handleErrorMessage } from "@/utils";
|
||||
|
||||
const NAME = "OrderSubmission",
|
||||
_isWeixin = isWeixin();
|
||||
@ -545,7 +546,6 @@ export default {
|
||||
if (this.$deviceType == "app") {
|
||||
from.from = "app";
|
||||
}
|
||||
console.log(this.storeItems, this.systemStore);
|
||||
createOrder(this.orderGroupInfo.orderKey, {
|
||||
realName: this.contacts,
|
||||
phone: this.contactsTel,
|
||||
@ -565,105 +565,10 @@ export default {
|
||||
})
|
||||
.then((res) => {
|
||||
uni.hideLoading();
|
||||
const data = res.data;
|
||||
switch (data.status) {
|
||||
case "ORDER_EXIST":
|
||||
case "EXTEND_ORDER":
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
this.$yrouter.replace({
|
||||
path: "/pages/order/OrderDetails/index",
|
||||
query: {
|
||||
id: data.result.orderId,
|
||||
},
|
||||
});
|
||||
break;
|
||||
case "PAY_DEFICIENCY":
|
||||
break;
|
||||
|
||||
case "PAY_ERROR":
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
this.$yrouter.replace({
|
||||
path: "/pages/order/OrderDetails/index",
|
||||
query: {
|
||||
id: data.result.orderId,
|
||||
},
|
||||
});
|
||||
break;
|
||||
case "SUCCESS":
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
this.$yrouter.replace({
|
||||
path: "/pages/order/OrderDetails/index",
|
||||
query: {
|
||||
id: data.result.orderId,
|
||||
},
|
||||
});
|
||||
break;
|
||||
case "WECHAT_H5_PAY":
|
||||
// H5支付
|
||||
this.$yrouter.replace({
|
||||
path: "/pages/order/OrderDetails/index",
|
||||
query: {
|
||||
id: data.result.orderId,
|
||||
},
|
||||
});
|
||||
setTimeout(() => {
|
||||
// location.href = data.result.jsConfig.mweb_url;
|
||||
}, 100);
|
||||
break;
|
||||
case "WECHAT_PAY":
|
||||
// 小程序支付
|
||||
weappPay(data.result.jsConfig).finally(() => {
|
||||
this.$yrouter.replace({
|
||||
path: "/pages/order/OrderDetails/index",
|
||||
query: {
|
||||
id: data.result.orderId,
|
||||
},
|
||||
});
|
||||
});
|
||||
break;
|
||||
|
||||
case "WECHAT_APP_PAY":
|
||||
// APP支付
|
||||
weappPay(data.result.jsConfig).finally(() => {
|
||||
this.$yrouter.replace({
|
||||
path: "/pages/order/OrderDetails/index",
|
||||
query: {
|
||||
id: data.result.orderId,
|
||||
},
|
||||
});
|
||||
});
|
||||
break;
|
||||
// 下面为原先微信支付方式,
|
||||
// pay(data.result.jsConfig).finally(() => {
|
||||
// this.$yrouter.replace({
|
||||
// path: "/pages/order/OrderDetails/index" ,query: { id: data.result.orderId}
|
||||
// });
|
||||
// });
|
||||
}
|
||||
handleOrderPayResults.call(this, res.data, "create");
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title:
|
||||
err.msg ||
|
||||
err.response.data.msg ||
|
||||
err.response.data.message ||
|
||||
"创建订单失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
handleErrorMessage(err, "创建订单失败");
|
||||
});
|
||||
},
|
||||
},
|
||||
|
@ -10,6 +10,8 @@ import dayjs from "dayjs";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import stringify from "@/utils/querystring";
|
||||
import { VUE_APP_API_URL } from "@/config";
|
||||
import { wechat, auth, oAuth } from '@/libs/wechat'
|
||||
|
||||
|
||||
export function dataFormat(time, option) {
|
||||
time = +time * 1000;
|
||||
@ -59,7 +61,7 @@ export function isType(arg, type) {
|
||||
}
|
||||
|
||||
export function isWeixin() {
|
||||
return false
|
||||
return navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1;
|
||||
}
|
||||
|
||||
export function parseQuery() {
|
||||
@ -152,10 +154,36 @@ export const authorize = (authorizeStr) => {
|
||||
}
|
||||
|
||||
export const login = () => {
|
||||
console.log('————————————————————')
|
||||
console.log('开始登录')
|
||||
console.log('————————————————————')
|
||||
console.log(Vue.prototype)
|
||||
return new Promise((resolve, reject) => {
|
||||
if (Vue.prototype.$deviceType == 'weixin') {
|
||||
// 微信授权登录
|
||||
wechat().then(() => oAuth().then((code) => {
|
||||
// const { code } = parseQuery()
|
||||
auth(code)
|
||||
.then(() => {
|
||||
// location.replace(
|
||||
// decodeURIComponent(decodeURIComponent(this.$route.params.url))
|
||||
// );
|
||||
location.href = decodeURIComponent(
|
||||
decodeURIComponent(this.$route.params.url)
|
||||
);
|
||||
})
|
||||
.catch(() => {
|
||||
reject('当前运行环境为微信浏览器')
|
||||
location.replace("/pages/home/index");
|
||||
});
|
||||
}));
|
||||
return
|
||||
}
|
||||
if (Vue.prototype.$deviceType == 'weixinh5') {
|
||||
|
||||
reject('当前运行环境为H5')
|
||||
return
|
||||
}
|
||||
console.log('————————————————————')
|
||||
console.log('开始登录')
|
||||
console.log('————————————————————')
|
||||
console.log('获取环境商')
|
||||
getProvider().then(provider => {
|
||||
console.log('当前的环境商')
|
||||
@ -328,7 +356,7 @@ export function parseRoute($mp) {
|
||||
}
|
||||
}
|
||||
|
||||
export function auth() {
|
||||
export function handleAuth() {
|
||||
/**
|
||||
* 如何判断权限?
|
||||
* 用户如果登录了系统,会留下两个东西,一个是token,一个是userInfo
|
||||
@ -378,7 +406,7 @@ export const handleLoginStatus = (location, complete, fail, success) => {
|
||||
}
|
||||
|
||||
// 判断用户是否有token
|
||||
if (!auth()) {
|
||||
if (!handleAuth()) {
|
||||
page.map((item) => {
|
||||
if (item.path == path) {
|
||||
isAuth = true
|
||||
@ -884,3 +912,18 @@ export function chooseImage(callback) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export function handleErrorMessage(err) {
|
||||
console.log(err)
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title:
|
||||
err.msg ||
|
||||
err.response.data.msg ||
|
||||
err.response.data.message ||
|
||||
"创建订单失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
|
@ -1,4 +1,11 @@
|
||||
// #ifndef MP-WEIXIN
|
||||
import Fly from "flyio/dist/npm/fly";
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
import Fly from "flyio/dist/npm/wx";
|
||||
// #endif
|
||||
|
||||
import $store from "../store";
|
||||
import { handleLoginFailure } from "@/utils";
|
||||
import { VUE_APP_API_URL } from "@/config";
|
||||
|
Reference in New Issue
Block a user