浏览代码

feat[litemall-wx, litemall-wx-api]: 关于页面读取后端配置信息

Junling Bu 6 年之前
父节点
当前提交
ca9830aac9

+ 16 - 0
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxHomeController.java

@@ -175,4 +175,20 @@ public class WxHomeController {
         }
         return categoryList;
     }
+
+    /**
+     * 商城介绍信息
+     * @return 商城介绍信息
+     */
+    @GetMapping("/about")
+    public Object about() {
+        Map<String, Object> about = new HashMap<>();
+        about.put("name", SystemConfig.getMallName());
+        about.put("address", SystemConfig.getMallAddress());
+        about.put("phone", SystemConfig.getMallPhone());
+        about.put("qq", SystemConfig.getMallQQ());
+        about.put("longitude", SystemConfig.getMallLongitude());
+        about.put("latitude", SystemConfig.getMallLatitude());
+        return ResponseUtil.ok(about);
+    }
 }

+ 2 - 1
litemall-wx/config/api.js

@@ -10,6 +10,8 @@ var WxApiRoot = 'http://localhost:8080/wx/';
 
 module.exports = {
   IndexUrl: WxApiRoot + 'home/index', //首页数据接口
+  AboutUrl: WxApiRoot + 'home/about', //介绍信息
+
   CatalogList: WxApiRoot + 'catalog/index', //分类目录全部分类数据接口
   CatalogCurrent: WxApiRoot + 'catalog/current', //分类目录当前分类数据接口
 
@@ -96,5 +98,4 @@ module.exports = {
 
   UserIndex: WxApiRoot + 'user/index', //个人页面用户相关信息
   IssueList: WxApiRoot + 'issue/list', //帮助信息
-
 };

+ 31 - 23
litemall-wx/pages/about/about.js

@@ -1,49 +1,57 @@
-// about.js
-var app = getApp()
-var util = require("../../utils/util.js");
+const util = require('../../utils/util.js');
+const api = require('../../config/api.js');
 
+//获取应用实例
+const app = getApp();
 
-var api = require("../../config/api.js");
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    load_statue: true,
-    shopInfo: {
-      name: 'litemall',
-      address: 'https://github.com/linlinjava/litemall',
-      latitude: 31.201900,
-      longitude: 121.587839,
-      linkPhone: '021-xxxx-xxxx',
-      qqNumber: '738696120'
-    },
+    name: 'litemall',
+    address: 'https://github.com/linlinjava/litemall',
+    latitude: '31.201900',
+    longitude: '121.587839',
+    phone: '021-xxxx-xxxx',
+    qq: '705144434'
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    
+    this.getAbout()
+  },
+  getAbout: function () {
+    let that = this;
+    util.request(api.AboutUrl).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          name: res.data.name,
+          address: res.data.address,
+          phone: res.data.phone,
+          qq: res.data.qq,
+          latitude: res.data.latitude,
+          longitude: res.data.longitude
+        });
+      }
+    });
   },
-
   showLocation: function (e) {
     var that = this
     wx.openLocation({
-      latitude: that.data.shopInfo.latitude,
-      longitude: that.data.shopInfo.longitude,
-      name: that.data.shopInfo.name,
-      address: that.data.shopInfo.address,
+      latitude: parseFloat(that.data.latitude),
+      longitude: parseFloat(that.data.longitude),
+      name: that.data.name,
+      address: that.data.address,
     })
   },
   callPhone: function (e) {
     var that = this
     wx.makePhoneCall({
-      phoneNumber: that.data.shopInfo.linkPhone,
+      phoneNumber: that.data.phone,
     })
-  },
-  reLoad: function (e) {
-    this.loadShopInfo();
   }
 })

+ 8 - 25
litemall-wx/pages/about/about.wxml

@@ -1,57 +1,40 @@
 <view class="container">
 
+  <view class="label">项目名称:</view>
   <view class="about-item">
-
     <view class="item-left">
-      <label>项目名称: </label>
-       <text>{{shopInfo.name}}</text> 
+      <text>{{name}}</text> 
     </view>
-
   </view>
 
+  <view class="label">项目地址:</view>
   <view class="about-item">
     <view class="item-left">
-      <label>项目地址: </label>
-       <text>{{shopInfo.address}}</text> 
+      <text>{{address}}</text> 
     </view>
-
     <view class="item-right" bindtap="showLocation">
       <image src="/static/images/ico-addr.png" class="right-icon"></image>
     </view>
   </view>
 
+  <view class="label">电话号码:</view>
   <view class="about-item">
     <view class="item-left">
-      <label>电话号码:    </label>
-       <text>{{shopInfo.linkPhone}}</text> 
+      <text>{{phone}}</text> 
     </view>
     <view class="item-right" bindtap="callPhone">
       <image src="/static/images/telephone.png" class="right-icon"></image>
     </view>
   </view>
 
+  <view class="label">QQ交流群: </view>
   <view class="about-item">
     <view class="item-left">
-      <label>QQ交流群: </label>
-       <text>{{shopInfo.qqNumber}}</text> 
+      <text>{{qq}}</text> 
     </view>
     <view class="item-right">
       <image src="/static/images/mobile.png" class="right-icon"></image>
     </view>
   </view>
 
-  <view class="about-item">
-    <view class="item-left">
-      <label>当前版本: </label>
-       <text>1.0.0</text> 
-    </view>
-  </view>
-
-  <view class="about-item">
-    <view class="item-left">
-      <label>开源协议: </label>
-       <text>MIT</text> 
-    </view>
-  </view>
-
 </view>

+ 10 - 18
litemall-wx/pages/about/about.wxss

@@ -1,19 +1,11 @@
 /* about.wxss */
 
-page{
-  height: 100%;
-  background-color: #F2f2f2;
-}
-.page-view{
-  height: 100%;
-}
-.banner-image{
-  width: 100%;
-  height: 350rpx;
-  background: #ee1;
-  margin-bottom: 30rpx;
-  border-bottom: solid #f2f2f2 0.5dp;
-}
+.label {
+  font-size: 26rpx;
+  margin-left: 20rpx;
+  padding: 10rpx 0;
+} 
+
 
 .about-item{
   background: white;
@@ -27,18 +19,18 @@ page{
 }
 
 .item-left{
-  font-size: 32rpx;
-  margin-left: 15rpx;
+  font-size: 38rpx;
+  margin-left: 40rpx;
   margin-top: auto;
   margin-bottom: auto;
 }
+
 .item-right{
-   
   margin-right: 15rpx;
   margin-top: auto;
   margin-bottom: auto;
 }
 .right-icon{
   width: 40rpx;
-   height: 40rpx;
+  height: 40rpx;
 }