瀏覽代碼

代码回滚

weixin_52219567 3 周之前
父節點
當前提交
5a99dd161e
共有 9 個文件被更改,包括 182 次插入189 次删除
  1. 2 2
      .env.development
  2. 113 113
      src/App.vue
  3. 1 1
      src/app/api/diy.ts
  4. 1 1
      src/app/pages/index/index.vue
  5. 1 1
      src/components/loading-page/loading-page.vue
  6. 3 2
      src/hooks/useDiy.ts
  7. 36 36
      src/hooks/useShare.ts
  8. 3 4
      src/utils/request.ts
  9. 22 29
      vite.config.ts

+ 2 - 2
.env.development

@@ -1,10 +1,10 @@
 NODE_ENV = 'development'
 
 # api请求地址
-VITE_APP_BASE_URL='http://yp1.yingpaipay.com:9026/'
+VITE_APP_BASE_URL=''
 
 # 图片服务器地址
-VITE_IMG_DOMAIN='https://v6.site.niucloud.com/'
+VITE_IMG_DOMAIN=''
 
 # 本地存储时token的参数名
 VITE_REQUEST_STORAGE_TOKEN_KEY='wapToken'

+ 113 - 113
src/App.vue

@@ -91,119 +91,119 @@ onLaunch((data: any) => {
     // #endif
 
     // 获取初始化数据信息
-    // useSystemStore().getInitFn(async () => {
-
-    //     const configStore = useConfigStore()
-
-    //     let loginConfig = uni.getStorageSync('login_config')
-    //     if (!loginConfig) {
-    //         loginConfig = deepClone(configStore.login)
-    //     }
-
-    //     let url: any = currRoute()
-    //     // 设置主色调
-    //     setThemeColor(url)
-
-    //     // 判断账号锁定后在登录注册页面不进行请求三方登录注册,防止在页面出不去 member_lock 为账号锁定标识
-    //     if (uni.getStorageSync('member_lock') && (['app/pages/auth/index', 'app/pages/auth/login', 'app/pages/auth/register', 'app/pages/auth/resetpwd'].indexOf(url) != -1) && (loginConfig.is_username || loginConfig.is_mobile || loginConfig.is_bind_mobile)) {
-    //         return false
-    //     }
-
-    //     // 判断是否已登录
-    //     if (getToken()) {
-    //         const memberStore: any = useMemberStore()
-
-    //         await memberStore.setToken(getToken(), () => {
-    //             if (!uni.getStorageSync('openid')) {
-    //                 const memberInfo = useMemberStore().info
-    //                 const login = useLogin()
-
-    //                 // #ifdef MP-WEIXIN
-    //                 if (memberInfo.mobile) uni.setStorageSync('wap_member_mobile', memberInfo.mobile) // 存储会员手机号,防止重复请求微信获取手机号接口
-    //                 if (memberInfo && memberInfo.weapp_openid) {
-    //                     uni.setStorageSync('openid', memberInfo.weapp_openid) // 授权登录后存储openid
-    //                 } else {
-    //                     login.getAuthCode({ updateFlag: true }) // 更新openid
-    //                 }
-    //                 // #endif
-
-    //                 // #ifdef H5
-    //                 if (isWeixinBrowser()) {
-    //                     if (memberInfo && memberInfo.wx_openid) {
-    //                         uni.setStorageSync('openid', memberInfo.wx_openid)
-    //                     } else {
-    //                         if (data.query.code) {
-    //                             // 检测身份是否合法(当前登录的账号是不是我的),openid有效后才能更新登录
-    //                             login.updateOpenid(data.query.code, () => {
-    //                                 login.authLogin({ code: data.query.code })
-    //                             })
-    //                         } else if (loginConfig.is_auth_register && loginConfig.is_force_access_user_info) {
-    //                             // 强制获取用户信息
-    //                             login.getAuthCode({ scopes: 'snsapi_userinfo' })
-    //                         } else {
-    //                             // 静默获取
-    //                             login.getAuthCode({ scopes: 'snsapi_base' })
-    //                         }
-    //                     }
-    //                 }
-    //                 // #endif
-
-    //             }
-
-    //             // todo 已注册的会员不受影响
-    //             // 开启强制绑定手机号
-    //             if (uni.getStorageSync('isBindMobile')) {
-    //                 uni.removeStorageSync('isBindMobile');
-    //             }
-    //             //
-    //             // if (loginConfig.is_bind_mobile && !memberStore.info.mobile) {
-    //             //     // 强制绑定手机号
-    //             //     uni.setStorageSync('isBindMobile', true)
-    //             // }
-    //         })
-
-    //     }
-
-    //     if (!getToken()) {
-
-    //         // #ifdef MP
-    //         // 小程序 会员退出后不会自动登录
-    //         if (uni.getStorageSync('autoLoginLock')) return;
-    //         // #endif
-
-    //         const login = useLogin()
-
-    //         // #ifdef MP
-    //         // 第三方平台自动注册登录
-    //         login.getAuthCode()
-    //         // #endif
-
-    //         // #ifdef H5
-    //         if (isWeixinBrowser()) {
-    //             if (uni.getStorageSync('autoLoginLock') && !uni.getStorageSync('wechat_login_back')) return;
-    //             if (uni.getStorageSync('wechat_login_back')) {
-    //                 uni.removeStorageSync('wechat_login_back') // 删除微信公众号手动授权登录回调标识
-    //                 if (data.query.code) {
-    //                     login.authLogin({ code: data.query.code })
-    //                 }
-    //             } else if (loginConfig.is_auth_register && loginConfig.is_force_access_user_info) {
-    //                 // 开启自动注册会员,并且强制获取用户信息
-    //                 // 检测是否已授权获取用户信息
-    //                 // let nickname = uni.getStorageSync('nickname');
-    //                 // let avatar = uni.getStorageSync('avatar');
-    //                 // let openid = uni.getStorageSync('openid');
-    //                 // if (!nickname || !avatar || !openid) {}
-    //                 login.getAuthCode({ scopes: 'snsapi_userinfo' })
-    //             } else {
-    //                 // 检测是否已授权获取用户信息
-    //                 // let openid = uni.getStorageSync('openid');
-    //                 // if (!openid) {}
-    //                 login.getAuthCode({ scopes: 'snsapi_base' }) // 静默获取
-    //             }
-    //         }
-    //         // #endif
-    //     }
-    // })
+    useSystemStore().getInitFn(async () => {
+
+        const configStore = useConfigStore()
+
+        let loginConfig = uni.getStorageSync('login_config')
+        if (!loginConfig) {
+            loginConfig = deepClone(configStore.login)
+        }
+
+        let url: any = currRoute()
+        // 设置主色调
+        setThemeColor(url)
+
+        // 判断账号锁定后在登录注册页面不进行请求三方登录注册,防止在页面出不去 member_lock 为账号锁定标识
+        if (uni.getStorageSync('member_lock') && (['app/pages/auth/index', 'app/pages/auth/login', 'app/pages/auth/register', 'app/pages/auth/resetpwd'].indexOf(url) != -1) && (loginConfig.is_username || loginConfig.is_mobile || loginConfig.is_bind_mobile)) {
+            return false
+        }
+
+        // 判断是否已登录
+        if (getToken()) {
+            const memberStore: any = useMemberStore()
+
+            await memberStore.setToken(getToken(), () => {
+                if (!uni.getStorageSync('openid')) {
+                    const memberInfo = useMemberStore().info
+                    const login = useLogin()
+
+                    // #ifdef MP-WEIXIN
+                    if (memberInfo.mobile) uni.setStorageSync('wap_member_mobile', memberInfo.mobile) // 存储会员手机号,防止重复请求微信获取手机号接口
+                    if (memberInfo && memberInfo.weapp_openid) {
+                        uni.setStorageSync('openid', memberInfo.weapp_openid) // 授权登录后存储openid
+                    } else {
+                        login.getAuthCode({ updateFlag: true }) // 更新openid
+                    }
+                    // #endif
+
+                    // #ifdef H5
+                    if (isWeixinBrowser()) {
+                        if (memberInfo && memberInfo.wx_openid) {
+                            uni.setStorageSync('openid', memberInfo.wx_openid)
+                        } else {
+                            if (data.query.code) {
+                                // 检测身份是否合法(当前登录的账号是不是我的),openid有效后才能更新登录
+                                login.updateOpenid(data.query.code, () => {
+                                    login.authLogin({ code: data.query.code })
+                                })
+                            } else if (loginConfig.is_auth_register && loginConfig.is_force_access_user_info) {
+                                // 强制获取用户信息
+                                login.getAuthCode({ scopes: 'snsapi_userinfo' })
+                            } else {
+                                // 静默获取
+                                login.getAuthCode({ scopes: 'snsapi_base' })
+                            }
+                        }
+                    }
+                    // #endif
+
+                }
+
+                // todo 已注册的会员不受影响
+                // 开启强制绑定手机号
+                if (uni.getStorageSync('isBindMobile')) {
+                    uni.removeStorageSync('isBindMobile');
+                }
+                //
+                // if (loginConfig.is_bind_mobile && !memberStore.info.mobile) {
+                //     // 强制绑定手机号
+                //     uni.setStorageSync('isBindMobile', true)
+                // }
+            })
+
+        }
+
+        if (!getToken()) {
+
+            // #ifdef MP
+            // 小程序 会员退出后不会自动登录
+            if (uni.getStorageSync('autoLoginLock')) return;
+            // #endif
+
+            const login = useLogin()
+
+            // #ifdef MP
+            // 第三方平台自动注册登录
+            login.getAuthCode()
+            // #endif
+
+            // #ifdef H5
+            if (isWeixinBrowser()) {
+                if (uni.getStorageSync('autoLoginLock') && !uni.getStorageSync('wechat_login_back')) return;
+                if (uni.getStorageSync('wechat_login_back')) {
+                    uni.removeStorageSync('wechat_login_back') // 删除微信公众号手动授权登录回调标识
+                    if (data.query.code) {
+                        login.authLogin({ code: data.query.code })
+                    }
+                } else if (loginConfig.is_auth_register && loginConfig.is_force_access_user_info) {
+                    // 开启自动注册会员,并且强制获取用户信息
+                    // 检测是否已授权获取用户信息
+                    // let nickname = uni.getStorageSync('nickname');
+                    // let avatar = uni.getStorageSync('avatar');
+                    // let openid = uni.getStorageSync('openid');
+                    // if (!nickname || !avatar || !openid) {}
+                    login.getAuthCode({ scopes: 'snsapi_userinfo' })
+                } else {
+                    // 检测是否已授权获取用户信息
+                    // let openid = uni.getStorageSync('openid');
+                    // if (!openid) {}
+                    login.getAuthCode({ scopes: 'snsapi_base' }) // 静默获取
+                }
+            }
+            // #endif
+        }
+    })
 
     // 控制弹窗展示
     uni.setStorageSync('isOnLoad', true); // 存储是页面是否加载完成的状态

+ 1 - 1
src/app/api/diy.ts

@@ -4,7 +4,7 @@ import request from '@/utils/request'
  * 获取自定义页面信息
  */
 export function getDiyInfo(params: Record<string, any>) {
-    return request.get('/mall/miniDiyPcPage/getMiniDiyPage', params)
+    return request.get('diy/diy', params)
 }
 
 /**

+ 1 - 1
src/app/pages/index/index.vue

@@ -35,7 +35,7 @@ const { setShare } = useShare()
 uni.hideTabBar() // 隐藏tabbar
 
 const diy = useDiy({
-    type: '1'
+    name: 'DIY_INDEX'
 })
 
 const diyGroupRef = ref(null)

+ 1 - 1
src/components/loading-page/loading-page.vue

@@ -13,7 +13,7 @@ const props = defineProps({
 		default: false
 	},
 	iconSize: {
-		type: [String, Number], 
+		type: String || Number,
 		default: 30
 	},
 	bgColor: {

+ 3 - 2
src/hooks/useDiy.ts

@@ -11,7 +11,6 @@ export function useDiy(params: any = {}) {
 
     const id = ref(0)
     const name = ref(params.name || '')
-	const type = ref(params.type || '')
     const template = ref('')
     const currRoute = ref('') //当前路由
     const requestData: any = reactive({});
@@ -104,7 +103,9 @@ export function useDiy(params: any = {}) {
                 diyStore.init();
             } else {
                 getDiyInfo({
-                    type: type.value
+                    id: id.value,
+                    name: name.value,
+                    template: template.value
                 }).then((res: any) => {
                     Object.assign(requestData, res.data);
                     if (requestData.value) {

+ 36 - 36
src/hooks/useShare.ts

@@ -88,45 +88,45 @@ export const useShare = () => {
                 // #endif
             }
         } 
-        // getShareInfo({
-        //        route: '/' + currRoute(),
-        //        params: JSON.stringify(currShareRoute().params)
-        //    }).then((res: any) => {
-        //     let data = res.data;
+        getShareInfo({
+               route: '/' + currRoute(),
+               params: JSON.stringify(currShareRoute().params)
+           }).then((res: any) => {
+            let data = res.data;
 
-        //     let wechat = data.wechat;
-        //     if (wechat) {
-        //         wechatOptions.title = wechat.title
-        //         wechatOptions.desc = wechat.desc
-        //         wechatOptions.imgUrl = wechat.url ? img(wechat.url) : ''
-        //     } else {
-        //         wechatOptions.title = document ? document.title : ''
-        //         wechatOptions.desc = ''
-        //     }
-        //     // #ifdef H5
-        //     wechatShare()
-        //     // #endif
+            let wechat = data.wechat;
+            if (wechat) {
+                wechatOptions.title = wechat.title
+                wechatOptions.desc = wechat.desc
+                wechatOptions.imgUrl = wechat.url ? img(wechat.url) : ''
+            } else {
+                wechatOptions.title = document ? document.title : ''
+                wechatOptions.desc = ''
+            }
+            // #ifdef H5
+            wechatShare()
+            // #endif
 
-        //     let weapp = data.weapp;
-        //     if (weapp) {
-        //         weappOptions.title = weapp.title
-        //         weappOptions.imageUrl = weapp.url ? img(weapp.url) : ''
-        //     }
-        //     // #ifdef MP
-        //     if(!weappOptions.title && !weappOptions.imageUrl){
-        //         uni.setStorageSync('weappOptions', {})
-        //         return;
-        //     }
-        //     uni.setStorageSync('weappOptions', weappOptions)
-        //     // #endif
+            let weapp = data.weapp;
+            if (weapp) {
+                weappOptions.title = weapp.title
+                weappOptions.imageUrl = weapp.url ? img(weapp.url) : ''
+            }
+            // #ifdef MP
+            if(!weappOptions.title && !weappOptions.imageUrl){
+                uni.setStorageSync('weappOptions', {})
+                return;
+            }
+            uni.setStorageSync('weappOptions', weappOptions)
+            // #endif
             
-        //     useSystemStore().$patch((state) => {
-        //         state.shareOptions = {
-        //             wechatOptions,
-        //             weappOptions
-        //         }
-        //     })
-        // })
+            useSystemStore().$patch((state) => {
+                state.shareOptions = {
+                    wechatOptions,
+                    weappOptions
+                }
+            })
+        })
         
         useSystemStore().$patch((state) => {
             state.shareOptions = {

+ 3 - 4
src/utils/request.ts

@@ -104,8 +104,7 @@ class Request {
         this.requestInterceptors()
 
         const params = Object.assign(uni.$u.deepClone(this.config), config, {
-            // url: this.baseUrl + url,
-            url:url,
+            url: this.baseUrl + url,
             method
         })
 
@@ -120,7 +119,7 @@ class Request {
                 ...params,
                 success: res => {
                     const data = res.data
-                    if (data.code == 200) {
+                    if (data.code == 1) {
                         config.showSuccessMessage && uni.showToast({ title: data.msg, icon: 'none' })
                         resolve(data)
                     } else {
@@ -136,7 +135,7 @@ class Request {
                     reject(res)
                 },
                 complete: (res) => {
-                    // this.handleRequestFail(res)
+                    this.handleRequestFail(res)
                 }
             })
         })

+ 22 - 29
vite.config.ts

@@ -1,35 +1,28 @@
-import { defineConfig } from "vite";
-import uni from "@dcloudio/vite-plugin-uni";
-import WindiCSS from "vite-plugin-windicss";
-import MiniProgramTailwind from "@dcasia/mini-program-tailwind-webpack-plugin/rollup";
+import {defineConfig} from 'vite'
+import uni from '@dcloudio/vite-plugin-uni'
+import WindiCSS from 'vite-plugin-windicss'
+import MiniProgramTailwind from '@dcasia/mini-program-tailwind-webpack-plugin/rollup'
 
 const plugins = [
-  uni(),
-  WindiCSS({
-    scan: {
-      dirs: ["."], // 当前目录下所有文件
-      fileExtensions: ["vue", "js", "ts"], // 同时启用扫描vue/js/ts
-    },
-  }),
-];
+    uni(),
+    WindiCSS({
+        scan: {
+            dirs: ['.'], // 当前目录下所有文件
+            fileExtensions: ['vue', 'js', 'ts'] // 同时启用扫描vue/js/ts
+        }
+    })
+]
 
-process.env.UNI_PLATFORM == "mp-weixin" && plugins.push(MiniProgramTailwind());
+process.env.UNI_PLATFORM == 'mp-weixin' && plugins.push(MiniProgramTailwind())
 
 export default defineConfig({
-  server: {
-    host: "0.0.0.0",
-    proxy: {
-      "/mall": {
-        target: "http://yp1.yingpaipay.com:9026",
-        changeOrigin: true,
-        secure: false,
-      },
+    server: {
+        host: '0.0.0.0',
+        // port: 6666,
+        // open:true // vite项目启动时自动打开浏览器
     },
-    // port: 6666,
-    // open:true // vite项目启动时自动打开浏览器
-  },
-  plugins,
-  optimizeDeps: {
-    include: ["dayjs"],
-  },
-});
+    plugins,
+    optimizeDeps: {
+        include: ['dayjs']
+    }
+})