|
|
@@ -1,102 +1,90 @@
|
|
|
<script>
|
|
|
import store from '@/store'
|
|
|
- import { mapMutations, mapActions, mapGetters } from 'vuex'
|
|
|
- import { setTimeout } from 'timers'
|
|
|
- import { getUser, wxLoginFn } from '@/utils/auth'
|
|
|
- import { getDictionaries } from '@/api/mini'
|
|
|
- import util from "./utils/util";
|
|
|
+import { mapMutations, mapActions, mapGetters } from 'vuex'
|
|
|
+import { setTimeout } from 'timers'
|
|
|
+import { getUser, wxLoginFn } from '@/utils/auth'
|
|
|
+import { getDictionaries } from '@/api/mini'
|
|
|
+import util from "./utils/util";
|
|
|
import priceSocket from "./mixins/priceSocket";
|
|
|
-
|
|
|
- export default {
|
|
|
- mixins:[priceSocket],
|
|
|
- // 全端,数据共享,还可以解决页面初始化模板访问不到值得
|
|
|
- // 有坑 分包里的页面访问不到
|
|
|
- globalData: {},
|
|
|
- onLaunch() {
|
|
|
- // #ifdef H5
|
|
|
- // H5开发环境无法微信授权,使用固定的用户 shish 2020.4.30
|
|
|
- if (process.env.NODE_ENV == "development") {
|
|
|
- uni.setStorageSync(
|
|
|
- "token",
|
|
|
- "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfNTIifQ.eyJpc3MiOiJodHRwczpcL1wvYXBpLnNob3AuaHpnaGQuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2FwaS5zaG9wLmh6Z2hkLmNvbSIsImp0aSI6IjBfNTIiLCJpYXQiOjE2MTYxNTc2NjQsIm5iZiI6MTYxNjE1NzY2NCwiZXhwIjoxNjI0Nzk3NjY0LCJ1bmlxdWVJZCI6IjUyIiwic291cmNlSWQiOjB9.VzSekbSwSczMWsfdPVdrm3gZ-v9o3p01NbMVNT4nGZ4"
|
|
|
- );
|
|
|
- uni.setStorageSync("account", "0");
|
|
|
- getDictionaries({ token: uni.getStorageSync('token') }).then(res => {
|
|
|
- if (util.isEmpty(res)) {
|
|
|
- return false
|
|
|
- }
|
|
|
- store.commit('setDictionariesInfo', {
|
|
|
- ...res.data.dict,
|
|
|
- ...res.data
|
|
|
- })
|
|
|
+export default {
|
|
|
+ mixins:[priceSocket],
|
|
|
+ // 全端,数据共享,还可以解决页面初始化模板访问不到值得
|
|
|
+ // 有坑 分包里的页面访问不到
|
|
|
+ globalData: {},
|
|
|
+ onLaunch() {
|
|
|
+ // #ifdef H5
|
|
|
+ // H5开发环境无法微信授权,使用固定的用户 shish 2020.4.30
|
|
|
+ if (process.env.NODE_ENV == "development") {
|
|
|
+ uni.setStorageSync("token","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfNTIifQ.eyJpc3MiOiJodHRwczpcL1wvYXBpLnNob3AuaHpnaGQuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2FwaS5zaG9wLmh6Z2hkLmNvbSIsImp0aSI6IjBfNTIiLCJpYXQiOjE2MTYxNTc2NjQsIm5iZiI6MTYxNjE1NzY2NCwiZXhwIjoxNjI0Nzk3NjY0LCJ1bmlxdWVJZCI6IjUyIiwic291cmNlSWQiOjB9.VzSekbSwSczMWsfdPVdrm3gZ-v9o3p01NbMVNT4nGZ4")
|
|
|
+ uni.setStorageSync("account", "0")
|
|
|
+ getDictionaries({ token: uni.getStorageSync('token') }).then(res => {
|
|
|
+ if (util.isEmpty(res)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ store.commit('setDictionariesInfo', {
|
|
|
+ ...res.data.dict,
|
|
|
+ ...res.data
|
|
|
})
|
|
|
- }
|
|
|
- // #endif
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // #endif
|
|
|
|
|
|
- // 删除缓存
|
|
|
- if (process.env.NODE_ENV == 'production') {
|
|
|
- uni.removeStorageSync('shopUser')
|
|
|
- }
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- // wxLoginFn()
|
|
|
- // uni.clearStorage()
|
|
|
- const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
|
|
|
- uni.setStorageSync('account', extConfig.account)
|
|
|
+ // 删除缓存
|
|
|
+ if (process.env.NODE_ENV == 'production') {
|
|
|
+ uni.removeStorageSync('shopUser')
|
|
|
+ }
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
+ // wxLoginFn()
|
|
|
+ // uni.clearStorage()
|
|
|
+ const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
|
|
|
+ uni.setStorageSync('account', extConfig.account)
|
|
|
|
|
|
- // #endif
|
|
|
- wxLoginFn(true)
|
|
|
- .then(res => {
|
|
|
- //花店员工和未知身份可以访问的地址
|
|
|
- var urlArr = ['admin/shopAdmin/bind', 'pagesClient/official','pagesClient/member/bind','pagesShare/pay'];
|
|
|
- var redirectPage = res.redirectPage;
|
|
|
- var needRedirect = true;
|
|
|
- urlArr.forEach((item, index, array) => {
|
|
|
- if (redirectPage.indexOf(item) != -1) {
|
|
|
- needRedirect = false;
|
|
|
- }
|
|
|
- })
|
|
|
- if (needRedirect === true) {
|
|
|
- //员工
|
|
|
- if (res.data.admin.identity == '2') {
|
|
|
- // this.$util.pageTo({
|
|
|
- // url: "/admin/home/workbench",
|
|
|
- // type: 4
|
|
|
- // });
|
|
|
- //客户
|
|
|
- }else{
|
|
|
- if(this.option.style != 1){
|
|
|
- this.$util.pageTo({
|
|
|
- url: "/pagesClient/official/index",
|
|
|
- type: 2,
|
|
|
- query: {
|
|
|
- ...this.option
|
|
|
- }
|
|
|
- });
|
|
|
+ // #endif
|
|
|
+ wxLoginFn(true)
|
|
|
+ .then(res => {
|
|
|
+ //客户可以访问的页面
|
|
|
+ var urlArr = ['admin/shopAdmin/bind', 'pagesClient/official','pagesClient/member/bind','pagesShare/pay'];
|
|
|
+ var redirectPage = res.redirectPage;
|
|
|
+ var needRedirect = true;
|
|
|
+ urlArr.forEach((item, index, array) => {
|
|
|
+ if (redirectPage.indexOf(item) != -1) {
|
|
|
+ needRedirect = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (needRedirect === true) {
|
|
|
+ //客户访问不能查看的页面跳转去官网
|
|
|
+ if (res.data.shopAdminId == '0') {
|
|
|
+ this.$util.pageTo({
|
|
|
+ url: "/pagesClient/official/index",
|
|
|
+ type: 2,
|
|
|
+ query: {
|
|
|
+ ...this.option
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
- getUser(true)
|
|
|
- //获取门店信息
|
|
|
- this.setUserShopAll()
|
|
|
+ }
|
|
|
+ getUser(true)
|
|
|
+ //获取门店信息
|
|
|
+ this.setUserShopAll()
|
|
|
|
|
|
- })
|
|
|
- },
|
|
|
- onLoad(){
|
|
|
- // const pages = getCurrentPages();
|
|
|
- // const currentPage = pages[pages.length - 1];
|
|
|
- // const url = `/${currentPage.route}`;
|
|
|
- // console.log(1111,url)
|
|
|
- },
|
|
|
- onShow() {
|
|
|
- },
|
|
|
- onHide() {},
|
|
|
- onError(err) {
|
|
|
- console.error(err, '错误捕获')
|
|
|
- },
|
|
|
- methods: {
|
|
|
- ...mapActions(['setUserShopAll'])
|
|
|
- }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onLoad(){
|
|
|
+ // const pages = getCurrentPages();
|
|
|
+ // const currentPage = pages[pages.length - 1];
|
|
|
+ // const url = `/${currentPage.route}`;
|
|
|
+ // console.log(1111,url)
|
|
|
+ },
|
|
|
+ onShow() {
|
|
|
+ },
|
|
|
+ onHide() {},
|
|
|
+ onError(err) {
|
|
|
+ console.error(err, '错误捕获')
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapActions(['setUserShopAll'])
|
|
|
}
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|