Просмотр исходного кода

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss_wx_app

于继渤 2 лет назад
Родитель
Сommit
c8423ba8db

+ 2 - 5
api/pages/mst/moneyAccount.js

@@ -16,11 +16,8 @@ module.exports = {
   
     routeUrl: {
         moneyAccount: {
-            // 用name代替url,为了传递params,params和url不能一起使用
-            // add: {key: 'add', url: '/pages/index/index2'},
-          // 客户跟进
-          chooseOrg: { key: 'chooseOrg', url: '/package-basic-data/pages/org/choose-org/choose-org'  },
-         
+       
+          add: {key: 'add', url: './add/add'},
         }
     }
 };

+ 2 - 1
api/pages/other/setting.js

@@ -10,7 +10,8 @@
 module.exports = {
     settingService: {
         // 前缀
-        prefix: 'mdm-server-dkic-b1/common/setting/',
+        prefix: 'mdm-server-dkic-b1/wxapi/basic/setting/',
+        unifiedOrder:''
 
     },
 

+ 22 - 0
api/pages/other/wechatPay.js

@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright(c) 2024 dongke All rights reserved. / Confidential
+ * 类的信息:
+ *		1.程序名称:
+ *		2.功能描述:微信支付方法
+ * 编辑履历:
+ *		作者				日期					版本				修改内容
+ *		jyh		  	     2024-1-19       			1.00		       	新建
+ *******************************************************************************/
+module.exports = {
+    wechatPayService: {
+        // 前缀
+        prefix: 'mdm-server-dkic-b1/wxapi/basic/wechat/pay/',
+        unifiedOrder: 'unified_order',
+    },
+
+    routeUrl: {
+        wechatPay: {
+             
+        }
+    }
+};

+ 2 - 1
app.js

@@ -11,6 +11,7 @@ import './mixins/mixins.js';
 const common = require('./api/pages/common/common.js');
 const setting = require('./api/pages/other/setting.js');
 const company = require('./api/pages/other/company.js');
+const wechatPay = require('./api/pages/other/wechatPay.js');
 const user = require('./api/pages/core/user.js');
 const staff = require('./api/pages/mst/staff.js');
 const staffRight = require('./api/pages/mst/staffRight.js');
@@ -36,7 +37,7 @@ const inbound = require('./api/pages/ivt/inbound.js');
 const moneyAccount = require('./api/pages/mst/moneyAccount.js');
 
 // api服务路由文件
-var apiList = [common, setting, company, user, staff, staffRight, staffPurview, settingValue, customer, role, roleFun, org, roleSensitive, goodsBrand, goodsCategory, goodsSeries, unit, supplier, warehouse, saleChannel, goodsSku, basicData,customerMst,purchase,inbound,moneyAccount]
+var apiList = [common, setting, company, wechatPay,user, staff, staffRight, staffPurview, settingValue, customer, role, roleFun, org, roleSensitive, goodsBrand, goodsCategory, goodsSeries, unit, supplier, warehouse, saleChannel, goodsSku, basicData,customerMst,purchase,inbound,moneyAccount]
 
 const util = require('./utils/util.js')
 const baseMethod = require('./api/pages/baseMethod.js')

+ 4 - 1
app.json

@@ -103,7 +103,10 @@
                 "pages/inventory-check/inventory-check",
                 "pages/inventory-check/add/add",
                 "pages/inventory-check/detail/detail",
-                "pages/fund-account/fund-account"
+                "pages/fund-account/fund-account",
+                "pages/fund-account/add/add",
+                "pages/fund-account/detail/detail",
+                "pages/fund-account/account-category/account-category"
             ]
         },
         {

+ 66 - 0
package-inventory/pages/fund-account/account-category/account-category.js

@@ -0,0 +1,66 @@
+// package-inventory/pages/fund-account/account-category/account-category.js
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad(options) {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload() {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh() {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom() {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage() {
+
+    }
+})

+ 3 - 0
package-inventory/pages/fund-account/account-category/account-category.json

@@ -0,0 +1,3 @@
+{
+    "usingComponents": {}
+}

+ 2 - 0
package-inventory/pages/fund-account/account-category/account-category.wxml

@@ -0,0 +1,2 @@
+<!--package-inventory/pages/fund-account/account-category/account-category.wxml-->
+<text>package-inventory/pages/fund-account/account-category/account-category.wxml</text>

+ 1 - 0
package-inventory/pages/fund-account/account-category/account-category.wxss

@@ -0,0 +1 @@
+/* package-inventory/pages/fund-account/account-category/account-category.wxss */

+ 66 - 0
package-inventory/pages/fund-account/add/add.js

@@ -0,0 +1,66 @@
+// package-inventory/pages/fund-account/add/add.js
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad(options) {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload() {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh() {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom() {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage() {
+
+    }
+})

+ 3 - 0
package-inventory/pages/fund-account/add/add.json

@@ -0,0 +1,3 @@
+{
+    "usingComponents": {}
+}

+ 2 - 0
package-inventory/pages/fund-account/add/add.wxml

@@ -0,0 +1,2 @@
+<!--package-inventory/pages/fund-account/add/add.wxml-->
+<text>package-inventory/pages/fund-account/add/add.wxml</text>

+ 1 - 0
package-inventory/pages/fund-account/add/add.wxss

@@ -0,0 +1 @@
+/* package-inventory/pages/fund-account/add/add.wxss */

+ 66 - 0
package-inventory/pages/fund-account/detail/detail.js

@@ -0,0 +1,66 @@
+// package-inventory/pages/fund-account/detail/detail.js
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad(options) {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload() {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh() {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom() {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage() {
+
+    }
+})

+ 3 - 0
package-inventory/pages/fund-account/detail/detail.json

@@ -0,0 +1,3 @@
+{
+    "usingComponents": {}
+}

+ 2 - 0
package-inventory/pages/fund-account/detail/detail.wxml

@@ -0,0 +1,2 @@
+<!--package-inventory/pages/fund-account/detail/detail.wxml-->
+<text>package-inventory/pages/fund-account/detail/detail.wxml</text>

+ 1 - 0
package-inventory/pages/fund-account/detail/detail.wxss

@@ -0,0 +1 @@
+/* package-inventory/pages/fund-account/detail/detail.wxss */

+ 67 - 7
package-inventory/pages/fund-account/fund-account.js

@@ -14,21 +14,81 @@ const app = getApp()
 Page({
   mixins: [mixins],
 
-    /**
-     * 页面的初始数据
-     */
-    data: {
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
 
     // 路由
     routeObjName: 'moneyAccount',
-    },
+  },
 
-    /**
+  /**
    * @desc : 查询
    * @date : 2024/2/1 15:49
    * @author : 王英杰
    */
   getData(params) {
-    return this.excute(this.data.service, this.data.service.selectByCond, params);
+    return this.excute(this.data.service, 'wx_list_by', params);
+  },
+  /**
+   * @desc :   处理接口返回数据
+   * @date : 2024/2/1 15:49
+   * @author : 王英杰
+   */
+  handleSearchData(tableData) {
+    let list = []
+    list = util.convertToChildren(tableData, 'macTypeName', 'macName')
+    list.forEach(element => {
+      let balance = 0
+      if (element.children) {
+        element.children.forEach(subitem => {
+          balance = subitem.balance + balance
+        });
+        element.balance = balance
+      }
+    });
+    this.setData({
+      tableData: list
+    })
   },
+  /**
+   * @desc :   收起展开实践
+   * @date : 2024/2/1 15:49
+   * @author : 王英杰
+   */
+  collapseAndExpand(e) {
+    let index = e.currentTarget.dataset.index
+    let tableData = this.data.tableData
+    let item = tableData[index]
+    item.checked = !item.checked
+    tableData[index] = item
+    this.setData({
+      tableData
+    })
+  },
+
+  
+  /**
+  * @desc : 新建
+  * @date : 2024/2/1 15:49
+  * @author : 王英杰
+  */
+ toAdd() {
+  let _this = this
+  wx.navigateTo({
+    url: this.data.route.add.url,
+    events: {
+      // 回调后,在这里给页面赋值
+      bandData: function (e) {
+        _this.getData()
+      }
+    },
+    success: function (res) {
+      // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
+      res.eventChannel.emit('params', {})
+    }
+  })
+},
 })

+ 29 - 3
package-inventory/pages/fund-account/fund-account.wxml

@@ -11,10 +11,36 @@
 <van-empty wx:if="{{tableData.length<=0}}" description="暂无数据" />
 
 <!-- 列表区 -->
-<dk-list list="{{tableData}}"  title="macTypeName"  content="{{contentList}}"   bind:toDetail="toDetail" bind:toTitle="toTitle" bind:toStatus="toStatus" bind:toPoint="toPoint" routeObjName="{{routeObjName}}" buttonList="{{buttonList}}" bind:open="open"></dk-list>
+<view wx:for="{{tableData}}" wx:for-item="item" wx:for-index="index" data-item="{{item}}" wx:key="index" class="main-class">
+  <view class="main-foot-2" style="position: relative;">
+    <view class="corner-view" style="padding:20rpx">
+      <view style="display: flex;">
+        <view class="corner-view-text font" style="width: 60%;font-size: 15px;">{{item.macName}}</view>
+        <view style="width: 10%;">{{ item.balance?item.balance:0 }} </view>
+        <view style="width: 30%;text-align: right;" data-index="{{index}}" data-item="{{item}}" catch:tap="collapseAndExpand">
 
+          <van-icon wx:if="{{ item.checked }}" color="#bdb7b7" name="arrow-down" />
+          <van-icon wx:else color="#bdb7b7" name="arrow" /> 
+        </view>
+      </view>
+    </view>
+
+    <view style="background-color: white;">
+      <view wx:for="{{item.children}}" wx:for-item="item_" wx:if="{{item.checked}}" wx:for-index="index_" wx:key="index_" style="display: flex;padding:10rpx">
+        <view style="display: flex; font-size: 13px;width: 100%;margin:2vw">
+          <view style="flex: 1;">{{item_.macName}}</view>
+          <view style="margin-right: 5vw;">{{item_.balance?item_.balance:0}}</view>
+        </view> 
+      </view>
+    </view>
+  </view>
+</view>
 <van-divider wx:if="{{noMore}}" contentPosition="center" borderColor="#DCDCDC">到底了~</van-divider>
 <view style="height: 135rpx;"></view>
 
-<!-- 新建按钮 -->
-<dk-save-bottom flagTypeName="customers" totallength="{{totallength}}" bind:submit="toAdd" />
+
+<!--  保存 -->
+<view class="bottom-class">
+  <van-button custom-class="save-button-class" disabled="{{loading}}" loading="{{loading}}" bind:click="toAdd" type="default">新建
+  </van-button>
+</view>

+ 22 - 1
package-inventory/pages/fund-account/fund-account.wxss

@@ -1 +1,22 @@
-/* package-inventory/pages/fund-account/fund-account.wxss */
+
+/**底部的样式*/
+.bottom-class {
+	position: fixed;
+	bottom: 20rpx;
+	width: 100%;
+	align-items: center;
+	justify-content: center;
+	border-top: 2rpx solid #efefef;
+	z-index: 2;
+	display: flex;
+}
+
+/**底部保存按钮的样式*/
+.save-button-class {
+	width: 640rpx;
+	background: #1B365D !important;
+	border-radius: 15rpx !important;
+	color: #fff !important;
+	font-size: 16px !important;
+	font-weight: 500 !important;
+}

+ 34 - 29
pages/login/login.js

@@ -24,17 +24,18 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    // this.wx_login()
+    // 登录 授权电话
+    this.wx_login()
   },
 
   /**
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-    // 调转主页
-    wx.reLaunch({
-      url: '../../pages/company/company',
-    })
+    // // 调转主页
+    // wx.reLaunch({
+    //   url: '../../pages/company/company',
+    // })
   },
 
   /**
@@ -95,12 +96,13 @@ Page({
   gettoken() {
     let _this = this
     //  调用接口
-    _this.getTokenPromise().then(res => {
-      console.log("gettoken", res);
-      if (res.data.code === Constants.SUCESS_CODE) {
+    _this.getTokenPromise().then(res => { 
+      if (res.data.code === Constants.SUCESS_CODE) { 
         app.globalData.user = res.data.data
-        if (res.data.data.company == undefined || res.data.data.company.cpId == undefined || res.data.data.company.cpId == 2) {
-          console.log("gettoken", res);
+        app.globalData.token = res.data.data.accessToken
+        if (res.data.data.company == undefined
+          || res.data.data.company.cpId == undefined
+          || res.data.data.company.cpId == 2) {
           // 调转选择公司
           wx.reLaunch({
             url: '../../pages/company/company',
@@ -111,18 +113,9 @@ Page({
             url: '../../pages/home-page/home-page',
           })
         }
-
       }
       else if (res.data.code === 1015) {
-        // 电话 和 昵称
-        let param = {
-          userPhone: 15902409627,
-          userName: 'dk',
-          userWxid: app.globalData.openid
-        }
-        // 注册微信用户
-        _this.register(param)
-
+        // 当前用户未注册
       }
     })
   },
@@ -148,10 +141,12 @@ Page({
  */
   register(param) {
     let _this = this
-    api.request(Constants.SYS_OPENID_API + 'oauth/wx/register', 'POST', param).then(res => {
-      console.log("register", res);
+    api.request(Constants.SYS_OPENID_API + 'oauth/wx/register', 'POST', param).then(res => { 
+      console.log("register",res);
       if (res.data.code == Constants.SUCESS_CODE) {
-        // 调转选择公司
+        app.globalData.user = res.data.data
+        app.globalData.token = res.data.data.accessToken
+        调转选择公司
         wx.reLaunch({
           url: '../../pages/company/company',
         })
@@ -165,9 +160,10 @@ Page({
 * @date : 2022/5/12 13:49
 * @author : 姜永辉
 */
-  handleGetPhoneNumber(e) {
-    console.log("handleGetPhoneNumber", e);
-    this.getWechatMobileDecrypt(e.detail.encryptedData, e.detail.iv, app.globalData.session_key);
+  handleGetPhoneNumber(e) { 
+    if (e.detail.errMsg == 'getPhoneNumber:ok') {
+      this.getWechatMobileDecrypt(e.detail.encryptedData, e.detail.iv, app.globalData.sessionkey)
+    }
   },
 
   /**
@@ -177,15 +173,24 @@ Page({
    * @param {*} sessionKey 
    */
   getWechatMobileDecrypt(encryptedData, iv, sessionKey) {
+    let _this = this
     let param = {
       encryptedData: encryptedData,
       iv: iv,
       sessionKey: sessionKey,
     }
-    api.request(Constants.SYS_OPENID_API + 'oauth/wx/decrypt', 'POST', param).then(res => {
-      console.log("decrypt", res);
+    api.request(Constants.SYS_OPENID_API + 'oauth/wx/decrypt', 'POST', param).then(res => {  
       if (res.data.code === Constants.SUCESS_CODE) {
-        app.globalData.phoneNumber = res.data.phoneNumber
+        let tel = res.data.data.phoneNumber
+        app.globalData.phoneNumber = tel
+        // 电话 和 昵称
+        let param = {
+          userPhone: tel,
+          userName: tel,
+          userWxid: app.globalData.openid
+        }
+        // 注册微信用户
+        _this.register(param)
 
       }
     })

+ 1 - 4
pages/login/login.wxml

@@ -12,11 +12,8 @@
       泛家居建陶行业云服务
     </view>
     <view>
-
+      <button class="pf-btn-auth" open-type="getPhoneNumber" bindgetphonenumber="handleGetPhoneNumber" bindtap="closegetPhoneNumber">授权登陆</button>
     </view>
 
-    <view>
-      <button class="pf-btn-auth" 	open-type="getPhoneNumber" bindgetphonenumber="handleGetPhoneNumber" bindtap="closegetPhoneNumber">授权登陆</button>
-    </view>
   </view>
 </view>

+ 45 - 1
pages/mine/mine.js

@@ -25,7 +25,7 @@ Page({
     orgName: '沈阳浑南红心美凯龙店',
     // 路由
     routeObjName: 'setting',
-
+    wechatPayService: app.globalData['wechatPayService'],
 
     appCount: 0,
     noticeCount: 0,
@@ -126,6 +126,50 @@ Page({
   },
 
   /**
+  * @desc : 微信支付
+  * @date : 2022/5/12 13:49
+  * @author : 姜永辉
+  */
+  toPay(e) {
+    let params = {
+      openId: app.globalData.openid,
+      paymentSn: 'ord000000000001',
+    }
+    return this.excute(this.data.wechatPayService, this.data.wechatPayService.unifiedOrder, params).then(res => {
+      console.log("toPay", res);
+      if (res.data.code === Constants.SUCESS_CODE) {
+        var appid = res.data.data.appId
+        var timeStamp = res.data.data.timeStamp
+        var nonce_str = res.data.data.nonceStr
+        var pk = res.data.data.pack
+        var paySign = res.data.data.paySign
+        //调用微信支付
+        wx.requestPayment({
+          'appId': appid,
+          'timeStamp': timeStamp,
+          'nonceStr': nonce_str,
+          'package': pk,
+          'signType': 'MD5',
+          'paySign': paySign,
+          'success': function (res) {
+            console.log('success', res);
+
+          },
+          'fail': function (res) {
+            console.log('fail', res);
+          },
+          'complete': function (res) {
+            // console.log(res);
+            console.log('complete', res);
+          }
+        });
+
+      }
+    });
+
+  },
+
+  /**
   * @desc : 设置跳转
   * @date : 2022/5/12 13:49
   * @author : 姜永辉

+ 5 - 0
pages/mine/mine.wxml

@@ -413,6 +413,11 @@
   <view class="todo-view">
     <view class="todo-view-title" catch:tap="toSetting">{{$t['settingCommany']}}</view>
   </view>
+
+  <view style="height: 30rpx;"></view>
+  <view class="todo-view">
+    <view class="todo-view-title" catch:tap="toPay">微信支付</view>
+  </view>
   <view style="height: 30rpx;"></view>
   <view class="todo-view" style="display: flex;justify-content:space-between;align-items: center;">
     <view class="todo-view-title ">标准版</view>

+ 1 - 1
utils/api.js

@@ -59,7 +59,7 @@ function wxRequest(url, requestType, params) {
     let app = getApp(), header = {
       'content-type': 'application/json'
     }
-    var openId =app.globalData.open_id
+    var openId =app.globalData.openid
     if (app.globalData.user) {
       app.globalData.user.openId = openId 
       // 请求的Authorization