weixin_52219567 před 1 měsícem
rodič
revize
99e3731537
8 změnil soubory, kde provedl 187 přidání a 180 odebrání
  1. 1 1
      .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. 2 3
      src/hooks/useDiy.ts
  6. 36 36
      src/hooks/useShare.ts
  7. 4 3
      src/utils/request.ts
  8. 29 22
      vite.config.ts

+ 1 - 1
.env.development

@@ -1,7 +1,7 @@
 NODE_ENV = 'development'
 
 # api请求地址
-VITE_APP_BASE_URL='https://v6.site.niucloud.com/api/'
+VITE_APP_BASE_URL='http://yp1.yingpaipay.com:9026/'
 
 # 图片服务器地址
 VITE_IMG_DOMAIN='https://v6.site.niucloud.com/'

+ 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('diy/diy', params)
+    return request.get('/mall/miniDiyPcPage/getMiniDiyPage', params)
 }
 
 /**

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

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

+ 2 - 3
src/hooks/useDiy.ts

@@ -11,6 +11,7 @@ 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({});
@@ -103,9 +104,7 @@ export function useDiy(params: any = {}) {
                 diyStore.init();
             } else {
                 getDiyInfo({
-                    id: id.value,
-                    name: name.value,
-                    template: template.value
+                    type: type.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 = {

+ 4 - 3
src/utils/request.ts

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

+ 29 - 22
vite.config.ts

@@ -1,28 +1,35 @@
-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',
-        // port: 6666,
-        // open:true // vite项目启动时自动打开浏览器
+  server: {
+    host: "0.0.0.0",
+    proxy: {
+      "/mall": {
+        target: "http://yp1.yingpaipay.com:9026",
+        changeOrigin: true,
+        secure: false,
+      },
     },
-    plugins,
-    optimizeDeps: {
-        include: ['dayjs']
-    }
-})
+    // port: 6666,
+    // open:true // vite项目启动时自动打开浏览器
+  },
+  plugins,
+  optimizeDeps: {
+    include: ["dayjs"],
+  },
+});