瀏覽代碼

1、增加共通混入方法

zhoux 2 年之前
父節點
當前提交
cc23b0d89b

+ 37 - 0
api/pages/baseMethod.js

@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright(c) 2024 dongke All rights reserved. / Confidential
+ * 类的信息:
+ *		1.程序名称:
+ *		2.功能描述:公共查询方法
+ * 编辑履历:
+ *		作者				日期					版本				修改内容
+ *		周兴		  	2024-1-19       			1.00		       	新建
+ *******************************************************************************/
+module.exports = {
+    baseService: {
+        // 新建
+        insert:'insert',
+        // 编辑
+        update:'update',
+        // 删除
+        delete:'delete',
+        // 停用
+        disable:'disable',
+        // 启用
+        enable:'enable',
+        // 批量新建
+        insertBatch:'insert_batch',
+        // 批量更新
+        updateBatch:'update_batch',
+        // 批量删除
+        deleteBatch:'delete_batch',
+        // 批量停用
+        disableBatch:'disable_batch',
+        // 批量启用
+        enableBatch:'enable_batch',
+        // 条件查询
+        selectByCond:'list_by',
+        // 根据条件查数量
+        countByCond:'count_by',
+    }
+};

+ 21 - 0
api/pages/baseRoute.js

@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright(c) 2024 dongke All rights reserved. / Confidential
+ * 类的信息:
+ *		1.程序名称:baseRoute
+ *		2.功能描述:公共路由
+ * 编辑履历:
+ *		作者				日期					版本				修改内容
+ *		周兴		  	2024-1-19       			1.00		       	新建
+ *******************************************************************************/
+module.exports = {
+    routeUrl : {
+        // 清空条件
+        clear: {key: 'clear'},
+        // 编辑 initFlag(是否进入加载基础数据的方法)
+        edit: {key: 'edit', method: 'edit', initFlag: true},
+        // 新建 initFlag(是否进入加载基础数据的方法)
+        add: {key: 'add', method: 'add', initFlag: true},
+        // 操作日志
+        log: {key: 'log', method: 'log'}
+      }
+};

+ 21 - 0
api/pages/common/common.js

@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright(c) 2024 dongke All rights reserved. / Confidential
+ * 类的信息:
+ *		1.程序名称:
+ *		2.功能描述:共通查询方法
+ * 编辑履历:
+ *		作者				日期					版本				修改内容
+ *		周兴		  	2024-1-19       			1.00		       	新建
+ *******************************************************************************/
+module.exports = {
+    commonService: {
+        prefix: 'mdm-server/mst/common/',
+        getBasicData: 'get_basic_data',
+        getCustomTag: 'get_customtag',
+        getCustomTagByPage: 'get_customtag_by_page',
+        getWebInitData: 'get_web_init_data',
+        getUser: 'get_user',
+        getUserByPage: 'get_user_by_page',
+        selectById: '',
+    },
+};

+ 34 - 0
api/pages/core/user.js

@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright(c) 2024 dongke All rights reserved. / Confidential
+ * 类的信息:
+ *		1.程序名称:
+ *		2.功能描述:用户查询方法
+ * 编辑履历:
+ *		作者				日期					版本				修改内容
+ *		周兴		  	2024-1-19       			1.00		       	新建
+ *******************************************************************************/
+module.exports = {
+    userService: {
+        // 前缀
+        prefix: '/mdm-server/core/user/',
+        // 更新密码
+        updatePassWord: 'update_password',
+        // 重置密码
+        resetPassword: 'reset_password',
+        // 解锁
+        unLock: 'un_lock',
+    },
+    
+    routeUrl : {
+        user: {
+            // 用name代替url,为了传递params,params和url不能一起使用
+            // add: {key: 'add', url: '/pages/index/index2'},
+            edit: {key: 'edit', url: 'user-edit'},
+            resetPassword: {key: 'resetPassword', method: 'resetPassword'},
+            unLock: {key: 'unLock', method: 'unLock'},
+            moduleRights: {key: 'moduleRights', method: 'moduleRights'},
+            enable: {key: 'enable', method: 'enable'},
+            disable: {key: 'disable', method: 'disable'},
+          }
+      }
+};

+ 68 - 2
app.js

@@ -5,11 +5,77 @@ import './utils/prototype/prototypeObject';
 import './utils/prototype/prototypeNumber';
 import './utils/prototype/prototypeNumber';
 import './utils/prototype/prototypeString';
 import './utils/prototype/prototypeString';
 import './utils/prototype/prototypeDatetime';
 import './utils/prototype/prototypeDatetime';
+import './mixins/mixins.js';
+import './api/pages/common/common.js';
+import './api/pages/core/user.js';
+const util = require('./utils/util.js')
+const baseMethod = require('./api/pages/baseMethod.js')
+const baseRoute = require('./api/pages/baseRoute.js')
+
+// 引入文件系统管理器模块
+const fs = wx.getFileSystemManager();
+// 要读取的文件夹路径
+const folderPath = '/api/pages'; // 将此处的'/path/to/folder'替换为实际的文件夹路径
+// 定义递归函数,用于读取指定目录下所有的.js文件
+function readJsFiles(dirPath) {
+  let returnFiles  = []
+  // 读取当前目录下的文件列表
+  const files = fs.readdirSync(dirPath);
+  for (let i = 0; i < files.length; i++) {
+    const file = files[i];
+    // 构建完整路径
+    const fullpath = dirPath + '/' + file;
+    // 如果是js文件就返回
+    if (file.endsWith('.js')) {
+      let item = require(fullpath);
+      if(file != 'baseMethod.js' && file != 'baseRoute.js'){
+        item.name = file.replace('.js','');
+        returnFiles.push(item);
+      }
+    }else if(fs.statSync(fullpath).isDirectory()){
+      // 如果是文件夹则递归调用自身处理子级文件夹
+      let returns = readJsFiles(fullpath);
+      returns.forEach(it=>{
+        returnFiles.push(it);
+      })
+    }
+  }
+  return returnFiles;
+}
 App({
 App({
   onLaunch() { 
   onLaunch() { 
     console.log("onLaunch");
     console.log("onLaunch");
   },
   },
   globalData: {
   globalData: {
-    userInfo: null
-  }
+    userInfo: null,
+  },
 })
 })
+try {
+  // 调用readdirSync()方法读取文件夹内容
+  let files = readJsFiles(folderPath);
+  let app = getApp();
+  let routeUrl = {}
+  files.forEach(m=>{
+    // console.log('values',values,m['routeUrl']);
+    app.globalData[Object.keys(m)[0]] =Object.assign( Object.values(m)[0],baseMethod.baseService)
+    // 如果没有路由,就建一个路由
+    if(!m['routeUrl']){
+      m['routeUrl'] = {}
+      m['routeUrl'][m.name] = {}
+      // 加入共通路由
+      m['routeUrl'][m.name] = Object.assign(m['routeUrl'][m.name],baseRoute.routeUrl)
+    }else{
+      util.objectMergeByMainJs(m['routeUrl'][m.name],baseRoute.routeUrl)
+    }
+
+    if(m.name != 'common'){
+      routeUrl[m.name] = m['routeUrl'][m.name];
+    }
+  })
+  app.globalData['routeUrl'] = routeUrl;
+  // 输出结果
+  console.log('文件列表:', files,baseMethod,routeUrl);
+} catch (error) {
+  console.error('读取文件夹失败:', error);
+}
+

+ 1 - 0
app.json

@@ -1,6 +1,7 @@
 {
 {
   "pages": [
   "pages": [
     "pages/index/index", 
     "pages/index/index", 
+    "pages/index/index2", 
     "pages/home-page/home-page",      
     "pages/home-page/home-page",      
     "pages/other/other",
     "pages/other/other",
     "pages/mine/mine",
     "pages/mine/mine",

+ 2 - 2
components/dkbase/dk-number-phone-input/dk-number-phone-input.js

@@ -1,5 +1,5 @@
 
 
-const Constants = require('../../../utils/Constants.js')
+const constants = require('../../../utils/constants.js')
 const util = require('../../../utils/util.js')
 const util = require('../../../utils/util.js')
 Component({
 Component({
   /**
   /**
@@ -91,7 +91,7 @@ Component({
     changeFieldblur(e) {
     changeFieldblur(e) {
       // 联系电话格式错误
       // 联系电话格式错误
       if (e.detail.value && e.detail.value != "") {
       if (e.detail.value && e.detail.value != "") {
-        var myreg = Constants.Mobile_Phone_Number_Regular_Expression
+        var myreg = constants.Mobile_Phone_Number_Regular_Expression
         if (!myreg.test(e.detail.value)) {
         if (!myreg.test(e.detail.value)) {
           this.setData({
           this.setData({
             errorMessageText: this.data.errorMessage
             errorMessageText: this.data.errorMessage

+ 2 - 2
components/dkbusiness/dk-label-multiple-select/dk-label-multiple-select.js

@@ -7,7 +7,7 @@
  *		于继渤		 2022-5-28			1.00		 筛选多选标签
  *		于继渤		 2022-5-28			1.00		 筛选多选标签
  *******************************************************************************/
  *******************************************************************************/
 const app = getApp()
 const app = getApp()
-const Constants = require('../../../utils/Constants.js');
+const constants = require('../../../utils/constants.js');
 const api = require('../../../utils/api.js');
 const api = require('../../../utils/api.js');
 Component({
 Component({
   /**
   /**
@@ -379,7 +379,7 @@ Component({
         dataSourceCode: dataSourceCode
         dataSourceCode: dataSourceCode
       }
       }
       return new Promise((resolve, reject) => {
       return new Promise((resolve, reject) => {
-        api.request(Constants.BASIC_COMMON_API + 'get_wx_init_data', 'POST', param).then(res => {
+        api.request(constants.BASIC_COMMON_API + 'get_wx_init_data', 'POST', param).then(res => {
           if (res.data.code === 200) {
           if (res.data.code === 200) {
             resolve(res.data)
             resolve(res.data)
           } else {
           } else {

+ 2 - 2
components/dkbusiness/dk-muti-dropdown-item/dk-muti-dropdown-item.js

@@ -9,7 +9,7 @@
  *******************************************************************************/
  *******************************************************************************/
 const api = require('../../../utils/api');
 const api = require('../../../utils/api');
 const app = getApp()
 const app = getApp()
-const Constants = require('../../../utils/Constants');
+const constants = require('../../../utils/constants');
 Component({
 Component({
   /**
   /**
    * 组件的属性列表
    * 组件的属性列表
@@ -227,7 +227,7 @@ Component({
         param.cpId = app.globalData.user.cpId
         param.cpId = app.globalData.user.cpId
       }
       }
       return new Promise((resolve, reject) => {
       return new Promise((resolve, reject) => {
-        api.request(Constants.BASIC_COMMON_API + 'get_wx_init_data', 'POST', param).then(res => {
+        api.request(constants.BASIC_COMMON_API + 'get_wx_init_data', 'POST', param).then(res => {
           if (res.data.code === 200) {
           if (res.data.code === 200) {
             resolve(res.data)
             resolve(res.data)
           } else {
           } else {

+ 2 - 2
components/dkbusiness/dk-single-dropdown-item/dk-single-dropdown-item.js

@@ -10,7 +10,7 @@
 
 
 const api = require('../../../utils/api');
 const api = require('../../../utils/api');
 const app = getApp()
 const app = getApp()
-const Constants = require('../../../utils/Constants');
+const constants = require('../../../utils/constants');
 Component({
 Component({
   /**
   /**
    * 组件的属性列表
    * 组件的属性列表
@@ -759,7 +759,7 @@ Component({
         param.channelId = this.data.channelId
         param.channelId = this.data.channelId
       }
       }
       return new Promise((resolve, reject) => {
       return new Promise((resolve, reject) => {
-        api.request(Constants.BASIC_COMMON_API + 'get_wx_init_data', 'POST', param).then(res => {
+        api.request(constants.BASIC_COMMON_API + 'get_wx_init_data', 'POST', param).then(res => {
           if (res.data.code === 200) {
           if (res.data.code === 200) {
             resolve(res)
             resolve(res)
           } else {
           } else {

+ 2 - 2
config/config.js

@@ -3,14 +3,14 @@ const profiles = 'test';
 const configListObj = {
 const configListObj = {
   // 北京东科企信软件有限公司 本地开发
   // 北京东科企信软件有限公司 本地开发
   dev: {
   dev: {
-    server_add: 'http://192.168.0.85',
+    server_add: 'http://192.168.0.57',
     server_port: '9001',
     server_port: '9001',
     server_img_http: 'https://hgscrm-dev.oss-cn-shenzhen.aliyuncs.com/',
     server_img_http: 'https://hgscrm-dev.oss-cn-shenzhen.aliyuncs.com/',
     server_hg_img_http: 'https://haip-dev.oss-cn-shenzhen.aliyuncs.com/',
     server_hg_img_http: 'https://haip-dev.oss-cn-shenzhen.aliyuncs.com/',
     corpid: 'ww796c5d1684937b2f', //企业微信corpid
     corpid: 'ww796c5d1684937b2f', //企业微信corpid
     corpsecret: '19mqS_rUn8YzK47LUmjIDEl6PAx1gcn9v0BRIbEAJXU', //秘钥
     corpsecret: '19mqS_rUn8YzK47LUmjIDEl6PAx1gcn9v0BRIbEAJXU', //秘钥
     key : '2PABZ-R3TKD-LAM4H-PJMTZ-6EW2O-2BBN7',//小程序插件 地图key
     key : '2PABZ-R3TKD-LAM4H-PJMTZ-6EW2O-2BBN7',//小程序插件 地图key
-    appid: 'wx414cffd0fc05e151',// 小程序id
+    appid: 'wx7b380afaab915872',// 小程序id
     server_vue: 'https://wechat.dkiboss.com:8110/'// 订单打印调用前台vue的网址
     server_vue: 'https://wechat.dkiboss.com:8110/'// 订单打印调用前台vue的网址
   },
   },
   // 北京东科企信软件有限公司 发版
   // 北京东科企信软件有限公司 发版

+ 322 - 0
mixins/index.js

@@ -0,0 +1,322 @@
+/*******************************************************************************
+ * Copyright(c) 2024 dongke All rights reserved. / Confidential
+ * 类的信息:
+ *		1.程序名称:
+ *		2.功能描述:一览界面混入
+ * 编辑履历:
+ *		作者				日期					版本				修改内容
+ *		周兴		  	2024-1-19       			1.00		       	新建
+ *******************************************************************************/
+const api = require('../utils/api.js');
+const constants = require('../utils/constants.js')
+const app = getApp()
+
+module.exports = {
+    data: {
+        // 加载中
+        loading: false,
+        // 没有更多
+        noMore:false,
+        // 路由名称
+        routeObjName:null,
+        // 主键Id
+        primaryKey:null,
+        // 分页
+        pageInfo: {
+            pageSize: constants.PAGE_SIZE,
+            currentPage: 1
+        },
+        // 查询条件实体
+        searchForm: null,
+        // 保存参数
+        params:null,
+        // 查询结果集
+        tableData:[],
+    },
+    /**
+     * @desc : 查询共通方法
+     * @author : 周兴
+     * @date : 2024/1/19
+     */
+    searchData(e) {
+        // 加载中
+        this.setData({
+            loading: true
+          })
+        // 给参数赋值
+        let params = this._setSearchParams();
+        this._getData(params).then(res=>{
+            this.setData({
+                loading: false
+            })
+            // res.data.data = {
+            //     code:200,
+            //     list:[{name:'t1',label:'t1'},{name:'t2',label:'t2'}],
+            //     message:''
+            //   }
+            if(res && res.code === constants.SUCESS_CODE){
+                let tableData = this.data.tableData;
+                let list = res.data.data.list;
+                if(!list || list.length === 0){
+                    // 如果不是翻页,需要清空
+                    if(e != 'more'){
+                        this.setData({
+                            list: [],
+                            noMore: false
+                        })
+                    }else{
+                        this.setData({
+                            noMore: true
+                        })
+                    }
+                    return;
+                }
+                // 如果返回数据小于页数,就不能再继续翻页了
+                if (list.length < this.data.pageInfo.pageSize) {
+                    this.setData({
+                        noMore: false
+                    })
+                }
+                // 把查询数据加入到结果集中
+                tableData = tableData.concat(list)
+                this.setData({
+                    tableData:tableData
+                })
+                console.log('table',this.data.tableData,tableData);
+                // 如果页面需要后续处理,再进行处理
+                if(this.handleData){
+                    this.handleData(tableData);
+                }
+            }
+        });
+    },
+    /**
+     * @desc : 给查询实体赋值
+     * @author : 周兴
+     * @date : 2024/1/19
+     */
+    _setSearchParams(){
+        let params = this.data.searchForm?this.data.searchForm:{};
+        params.pageSize = this.data.pageInfo.pageSize;
+        params.currentPage = this.data.pageInfo.currentPage;
+        if(this.setSearchParams){
+            // 调用参数赋值
+            params = this.setSearchParams(params);
+        }
+        return params;
+    },
+    /**
+     * @desc : 执行查询共通方法
+     * @author : 周兴
+     * @date : 2024/1/19
+     */
+    _getData(params){
+        return new Promise(resolve => {
+            let res = this.getData(params);
+            resolve(res);
+          })
+    },
+    /**
+     * @desc : 点击按钮
+     * @author : 周兴
+     * @date : 2024/1/22
+     */
+    open(e){
+        // 如果没有路由就不往下进行
+        if(!this.routeObjName)return;
+        let name;
+        let item;
+        if(typeof e === 'object'){
+            name = e.currentTarget.dataset.name;
+            item = e.currentTarget.dataset.item;
+            if(this.primaryKey){
+                item.id = item[this.primaryKey]
+            }
+        }else{
+            name = e;
+        }
+        let routeUrl = app.globalData['routeUrl'][this.routeObjName][name];
+        if(!routeUrl)return;
+        // 如果有链接,就跳转
+        // console.log('url',routeUrl);
+        if(routeUrl.url){
+            wx.navigateTo({
+                url: routeUrl.url,
+                success:function(res){
+                    res.eventChannel.emit('data',item);
+                }
+            })
+        }else{
+            // 如果是方法就执行方法
+            if(routeUrl.method){
+                this[routeUrl.method](item);
+            }
+        }
+    },
+    /**
+     * @desc : 执行保存方法
+     * @author : 周兴
+     * @date : 2024/1/22
+     */
+    save({saveFlag=true,url,dialogMes}){
+        // 校验
+        this._validData().then(res => {
+            if (!res) {
+              return;
+            }
+            this.loading = true;
+            // 设置参数
+            this._setParams();
+            // 如果需要有询问
+            if(dialogMes){
+                Dialog.confirm({
+                    message: dialogMes,
+                }).then(()=>{
+                    // 执行保存方法
+                    if(saveFlag){
+                        this._handleSaveData();
+                    }else{
+                        wx.navigateTo({
+                            url: url,
+                        })
+                    }
+                })
+            }else{
+                 // 执行保存方法
+                 if(saveFlag){
+                    this._handleSaveData();
+                }else{
+                    wx.navigateTo({
+                        url: url,
+                    })
+                }
+            }
+        });
+    },
+    /**
+     * @desc : 保存方法
+     * @author : 周兴
+     * @date : 2024/1/22
+     */
+    _handleSaveData(){
+        this._saveData(this.params).then(result=>{
+            this.setData({
+                loading: false
+              })
+            if(result.code = constants.SUCESS_CODE){
+                wx.showToast({
+                    title: '保存成功',
+                    image: '/static/image/success.png',
+                    duration: 1000
+                  })
+                  // 如果页面需要后续处理,再进行处理
+                  if(this.handleData){
+                    this.handleData();
+                  }
+            }else{
+                wx.showToast({
+                    title: result.message,
+                    image: '/static/image/warning.png',
+                    duration: 1000
+                })
+            }
+        });
+    },
+    /**
+     * @desc : 给查询实体赋值
+     * @author : 周兴
+     * @date : 2024/1/19
+     */
+    _setParams(){
+        params = {};
+        if(this.setParams){
+            // 调用参数赋值
+            this.setParams(params);
+        }
+    },
+    /**
+     * @desc   : 校验,(不给外部调用)
+     * @author : 周兴
+     * @date   : 2024/1/22 14:13
+     */
+    _validData() {
+        return new Promise(resolve => {
+          // 页面校验
+          if (this.validData) {
+            let flag = this.validData();
+            resolve(flag);
+          } else {
+            resolve(true);
+          }
+        })
+    },
+    /**
+     * @desc   : 给参数赋值(不给外部调用)
+     * @author : 周兴
+     * @date   : 2024/1/22 14:33
+     */
+    _saveData(params) {
+        return new Promise(resolve => {
+          let res = this.saveData(params);
+          resolve(res);
+        })
+    },
+    /**
+     * @desc : 执行方法
+     * @author : 周兴
+     * @date : 2024/1/22
+     */
+    excute(service, method, params,showMessage = true,button = ''){
+        if(service && method){
+            let res = api.request(service.prefix + method, 'POST', params);
+            if(res){
+                res.then(t =>{
+                    if(showMessage){
+                        if(t.code === constants.SUCESS_CODE){
+                            if(button == ''){
+                                button = constants.Messages.save_sucess;
+                            }
+                            wx.showToast({
+                                title: button,
+                                image: '/static/image/success.png',
+                                duration: 1000
+                            })
+                            if (searchFlag) {
+                                this.searchData();
+                            }
+                        }else{
+                            if (t.message) {
+                                wx.showToast({
+                                    title: t.message,
+                                    image: '/static/image/warning.png',
+                                    duration: 1000
+                                })
+                            }
+                        }
+                    }
+                })
+            }
+        }
+    },
+    onLoad() {
+        // this.searchData();
+    },
+    /**
+   * @desc : 页面上拉触底事件的处理函数
+   * @author : 于继渤
+   * @date : 2022/5/24 12:16
+   */
+    onReachBottom: function () {
+    if (this.data.loading || this.data.noMore) {
+      return;
+    }
+    this.setData({
+      pageInfo: {
+        pageSize: this.data.pageInfo.pageSize,
+        currentPage: this.data.pageInfo.currentPage + 1
+      }
+    })
+    // 执行查询方法
+    this.searchData('more')
+  },
+};

+ 37 - 0
mixins/mixins.js

@@ -0,0 +1,37 @@
+/**
+ * mixins 为 Page 增加 mixin 功能
+ */
+const originPage = Page;
+const originProperties = ['data', 'properties', 'options'];
+const originMethods = ['onLoad', 'onReady', 'onShow', 'onHide', 'onUnload', 'onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onPageScroll', 'onTabItemTap'];
+
+function merge (mixins, options) {
+    mixins.forEach((mixin) => {
+        if (Object.prototype.toString.call(mixin) !== '[object Object]') {
+            throw new Error('mixin 类型必须为对象!')
+        }
+        for (let [key, value] of Object.entries(mixin)) {
+            if (originProperties.includes(key)) {
+                options[key] = { ...value, ...options[key] }
+            } else if (originMethods.includes(key)) {
+                const originFunc = options[key];
+                options[key] = function (...args) {
+                    value.call(this, ...args);
+                    return originFunc && originFunc.call(this, ...args)
+                }
+            } else {
+                options = { ...mixin, ...options }
+            }
+        }
+    });
+    return options
+}
+
+Page = (options) => {
+    const mixins = options.mixins;
+    if (Array.isArray(mixins)) {
+        delete options.mixins;
+        options = merge(mixins, options)
+    }
+    originPage(options)
+};

+ 35 - 1
pages/index/index.js

@@ -7,10 +7,15 @@
  *		作者				日期					版本				修改内容
  *		作者				日期					版本				修改内容
  *		admin		  	2022-11-22			1.00		   	新建
  *		admin		  	2022-11-22			1.00		   	新建
  *******************************************************************************/
  *******************************************************************************/
+
 // 获取应用实例
 // 获取应用实例
+const api = require('../../utils/api.js');
 const app = getApp()
 const app = getApp()
+const index = require('../../mixins/index.js')
+const constants = require('../../utils/constants.js')
 
 
 Page({
 Page({
+  mixins: [index],
   data: {
   data: {
     datetime:new Date().getTime(),
     datetime:new Date().getTime(),
     motto: 'Hello World',
     motto: 'Hello World',
@@ -36,6 +41,9 @@ Page({
       },
       },
     }
     }
   },
   },
+  saveData(){
+    console.log('ttt',this.data.pageInfo);
+  },
   /**
   /**
    * 数据加载
    * 数据加载
    */
    */
@@ -46,8 +54,34 @@ Page({
     this.setData({
     this.setData({
       datetime:new Date().format('yyyy-MM-dd hh:mm:ss')
       datetime:new Date().format('yyyy-MM-dd hh:mm:ss')
     })
     })
+    this.routeObjName = 'user'
+    this.open('add');
+  },
+  add(params){
+    console.log('add',params);
+  },
+  /**
+   * @desc : 设置查询条件
+   * @author : 周兴
+   * @date : 2024/1/22
+   */
+  setSearchParams(params){
+    params.cpId = 20826
+    // params.ascpId = 20826
+    // params.currentPage = 1
+    // params.pageSize = 5
+    // params.docCode = '销售订单'
+    return params;
+  },
+  /**
+   * @desc : 执行查询
+   * @author : 周兴
+   * @date : 2024/1/22
+   */
+  getData(params){
+    return this.excute(app.globalData.commonService,app.globalData.commonService.selectByCond,params);
+    // return api.request(constants.PAGE_ITEM_MUST_API + '/list_by', 'POST', params);
   },
   },
-
 
 
   /**
   /**
    * Object.toFixed
    * Object.toFixed

+ 1 - 1
pages/index/index.wxml

@@ -4,7 +4,7 @@
   tofiexed函数:2.333的值:{{tofixedavelue}}
   tofiexed函数:2.333的值:{{tofixedavelue}}
 
 
 </view>
 </view>
-<loading></loading>
+<loading wx:if="{{loading}}" loadingName="加载中" backgroundColor="#f2f2f2;" opacity="0.8"></loading>
 <!--dk-cell测试  -->
 <!--dk-cell测试  -->
 <view style="width: 55%;">
 <view style="width: 55%;">
   <dk-cell titleStyle="color:red" title="cell标题" cell-horizontal-padding='14px' cell-vertical-padding='14px' cellValueColor='blue' bind:click="onClick">
   <dk-cell titleStyle="color:red" title="cell标题" cell-horizontal-padding='14px' cell-vertical-padding='14px' cellValueColor='blue' bind:click="onClick">

+ 70 - 0
pages/index/index2.js

@@ -0,0 +1,70 @@
+// pages/index/index2.js
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad(options) {
+        console.log('rrr',);
+        const eventChannel = this.getOpenerEventChannel();
+        eventChannel.on('data',function(data){
+          console.log('data',data);
+        })
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload() {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh() {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom() {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage() {
+
+    }
+})

+ 3 - 0
pages/index/index2.json

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

+ 2 - 0
pages/index/index2.wxml

@@ -0,0 +1,2 @@
+<!--pages/index/index2.wxml-->
+<text>pages/index/index2.wxml</text>

+ 1 - 0
pages/index/index2.wxss

@@ -0,0 +1 @@
+/* pages/index/index2.wxss */

+ 1 - 1
pages/mine/mine.js

@@ -20,7 +20,7 @@ Page({
    * 生命周期函数--监听页面加载
    * 生命周期函数--监听页面加载
    */
    */
   onLoad: function (options) {
   onLoad: function (options) {
-
+    
   },
   },
  
  
 
 

+ 3 - 2
project.config.json

@@ -45,11 +45,12 @@
         "disableUseStrict": false,
         "disableUseStrict": false,
         "minifyWXML": true,
         "minifyWXML": true,
         "showES6CompileOption": false,
         "showES6CompileOption": false,
-        "useCompilerPlugins": false
+        "useCompilerPlugins": false,
+        "condition": false
     },
     },
     "compileType": "miniprogram",
     "compileType": "miniprogram",
     "libVersion": "2.23.4",
     "libVersion": "2.23.4",
-    "appid": "wx04d4f4d8f7be02e9",
+    "appid": "wx7b380afaab915872",
     "projectname": "dk_wx_base",
     "projectname": "dk_wx_base",
     "condition": {},
     "condition": {},
     "editorSetting": {
     "editorSetting": {

+ 19 - 21
utils/Constants.js

@@ -1,26 +1,24 @@
- 
-//页面加载数据API
-const BASIC_COMMON_API = "mdm-server/wxapi/basic/common/"
- 
-/**
-* @desc : 最大的数量 
-* @author : 于继渤
-* @date : 2022/8/19 10:16
-*/
-const Mess_Max_Quantity = '超过最大值或最小值,最大值为9999999999.999999'
-
-/**
-* @desc : 手机号正则表达式 目前只有位数校验(11位)
-* @author : 于继渤
-* @date : 2022/8/19 10:16
-*/
-const Mobile_Phone_Number_Regular_Expression = /^[0-9][0-9][0-9]{9}$/;
- 
- 
 /**
 /**
   * 导出常量
   * 导出常量
   */
   */
 module.exports = {  
 module.exports = {  
-  BASIC_COMMON_API: BASIC_COMMON_API,  
-  Mobile_Phone_Number_Regular_Expression: Mobile_Phone_Number_Regular_Expression, 
+  //一页条数
+  PAGE_SIZE : 5,
+  // 成功的code
+  SUCESS_CODE : 200,
+  //页面加载数据API
+  BASIC_COMMON_API : "mdm-server/wxapi/basic/common/",
+  // 最大的数量 
+  Mess_Max_Quantity : '超过最大值或最小值,最大值为9999999999.999999',
+  // 手机号正则表达式 目前只有位数校验(11位)
+  Mobile_Phone_Number_Regular_Expression : /^[0-9][0-9][0-9]{9}$/,
+  // 提示信息
+  Messages:{
+    save_sucess:'保存成功',
+  },
+ 
+  //销售订单相关API
+  SALE_ORDER_API : "order-server/wxapi/sale/order/",
+  WARE_HOUSE : "mdm-server/mst/warehouse/",
+  PAGE_ITEM_MUST_API : "basic-server/basic/pageItemMust",
 };
 };

+ 1 - 1
utils/common.js

@@ -9,7 +9,7 @@
  *******************************************************************************/
  *******************************************************************************/
 var QQMapWX = require('./qqmap-wx-jssdk.min');
 var QQMapWX = require('./qqmap-wx-jssdk.min');
 const config = require('../config/config.js');
 const config = require('../config/config.js');
-const Constants = require('../utils/Constants.js');
+const constants = require('../utils/constants.js');
 const util = require('./util');
 const util = require('./util');
 
 
 const app = getApp();
 const app = getApp();

+ 1 - 1
utils/datetimeUtil.wxs

@@ -32,5 +32,5 @@ var formatNumber = function (n) {
  * //暴露接口调用
  * //暴露接口调用
  */
  */
 module.exports = {
 module.exports = {
-  format: format
+  // format: format
 }
 }

+ 29 - 2
utils/util.js

@@ -1,4 +1,4 @@
-const Constants = require('../utils/Constants.js')
+const constants = require('../utils/constants.js')
 
 
 // 转换时间
 // 转换时间
 const getDate = (year, month, day, hour, minute) => {
 const getDate = (year, month, day, hour, minute) => {
@@ -573,7 +573,7 @@ function jumpPageDate(type) {
 * @date : 2022/8/19 10:16
 * @date : 2022/8/19 10:16
 */
 */
 function isPoneAvailable(poneInput) {
 function isPoneAvailable(poneInput) {
-  var myreg = Constants.Mobile_Phone_Number_Regular_Expression
+  var myreg = constants.Mobile_Phone_Number_Regular_Expression
   if (!myreg.test(poneInput)) {
   if (!myreg.test(poneInput)) {
     return false;
     return false;
   } else {
   } else {
@@ -645,7 +645,34 @@ function isNumberNegative(n) {
   }
   }
 }
 }
 
 
+  /**
+   * @desc   : 合并实体(供main.js)调用,其他地方,调用上面那个
+   * @author : 周兴
+   * @date   : 2022/11/21 14:25
+   */
+  function objectMergeByMainJs(source, target) {
+    if (typeof source !== 'object') {
+      source = {};
+    }
+    if (Array.isArray(target)) {
+      return source.slice();
+    }
+    if (!source['key']) {
+      Object.keys(target).forEach((property) => {
+        const targetProperty = target[property];
+        if (typeof targetProperty === 'object') {
+          source[property] = this.objectMergeByMainJs(source[property], targetProperty);
+        } else {
+          source[property] = targetProperty;
+        }
+      });
+    }
+    return source;
+  }
+
+
 module.exports = {
 module.exports = {
+  objectMergeByMainJs:objectMergeByMainJs,
   updateProvince: updateProvince,
   updateProvince: updateProvince,
   isPoneAvailable: isPoneAvailable,
   isPoneAvailable: isPoneAvailable,
   formatTime: formatTime,
   formatTime: formatTime,