Bläddra i källkod

始宁农业小程序:新增系统配置接口

panyong 1 år sedan
förälder
incheckning
9102f0edcf

+ 10 - 0
htmldev/shiningWxMini/api/common.js

@@ -116,3 +116,13 @@ export const getShopDetail = (shopId) => request({
   },
   showLoading: true
 })
+
+/**
+ * 系统配置
+ * @returns {Promise<*>}
+ */
+export const getSystemConfig = () => request({
+  url: '/api/system/config',
+  method: 'POST',
+  showLoading: false
+}, false)

+ 12 - 2
htmldev/shiningWxMini/app.js

@@ -1,4 +1,4 @@
-const { getUserInfo } = require('./api/common')
+const { getUserInfo, getSystemConfig } = require('./api/common')
 const { isMobile } = require('./utils/validate')
 const { checkUpdateVersion } = require('./utils/util')
 
@@ -15,6 +15,7 @@ App({
     that.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right
     that.globalData.menuBottom = menuButtonInfo.top - systemInfo.statusBarHeight
     that.globalData.menuHeight = menuButtonInfo.height
+    that.fetchSystemConfig()
     that.fetchUserData()
     checkUpdateVersion()
   },
@@ -52,7 +53,8 @@ App({
         'iconPath': 'image/tabBar/news_0@2x.png',
         'selectedIconPath': 'image/tabBar/news_1@2x.png'
       }
-    ]
+    ],
+    objSystemConfig: {}
   },
   async fetchUserData() {
     try {
@@ -90,5 +92,13 @@ App({
         this.addTabBarList(tabBarList)
       }
     }
+  },
+  async fetchSystemConfig() {
+    try {
+      const { status, data } = await getSystemConfig()
+      if (status && Object.prototype.toString.call(data) === '[object Object]') {
+        this.globalData.objSystemConfig = data
+      }
+    } catch (err) {}
   }
 })

+ 11 - 3
htmldev/shiningWxMini/pages/mine/mine.js

@@ -26,7 +26,7 @@ Page({
       // 'shop_status': 0, // 状态(0审核中1审核通过2审核失败)
       // 'user_shop_id': 0 //店铺ID(0代表无店铺)
     },
-    kefu: '18551725991' // todo 客服电话
+    kefu: ''
   },
 
   /**
@@ -51,11 +51,13 @@ Page({
    */
   onShow() {
     const { shop_status } = app.globalData.userInfo
+    const { kefu_phone } = app.globalData.objSystemConfig
 
     this.getTabBar().init()
     this.setData({
       sessionId: wx.getStorageSync(sessionStorageKey),
-      userInfo: app.globalData.userInfo
+      userInfo: app.globalData.userInfo,
+      kefu: kefu_phone
     })
 
     if (shop_status === 1 && this.getTabBar().data.list.findIndex(item => item.pagePath === 'pages/news/news') === -1) {
@@ -197,8 +199,14 @@ Page({
     })
   },
   call() {
+    const { kefu } = this.data
+
+    if (!kefu) {
+      return
+    }
+
     wx.makePhoneCall({
-      phoneNumber: this.data.kefu
+      phoneNumber: kefu
     })
   },
   showLogout() {