wangxin 5 gadi atpakaļ
vecāks
revīzija
de34ea3444

+ 1 - 1
app.js

@@ -89,7 +89,7 @@ App({
     phone_zz: /1[0-9]{10}/,
     webview: null,
     version: '1.1.6',
-    platformId: 1
+    platformId: 5
   },
   /**
    * 需要监测的全局变量

+ 4 - 3
app.wxs

@@ -1,3 +1,4 @@
+// 格式化钱
 function formatMoney(num) {
   var _num = num - 0;
   if (isNaN(_num)) {
@@ -5,7 +6,7 @@ function formatMoney(num) {
   }
   return _num.toLocaleString();
 }
-
+// 格式化时间
 function formatTime(date, month_str, minute_str, status) {
   date = date.replace(getRegExp('-', 'g'), '/');
   var _date = null;
@@ -21,12 +22,12 @@ function formatTime(date, month_str, minute_str, status) {
   }
   return [year, month, day].map(formatNumber).join(month_str || '/') + ' ' + [hour, minute, second].map(formatNumber).join(minute_str || ':');
 }
-
+// 格式化数字
 function formatNumber(n) {
   n = n.toString();
   return n[1] ? n : '0' + n;
 }
-
+// 格式化价格
 function getPriceForm(number) {
   var _num = ((number - 0) / 1000).toLocaleString();
   if (isNaN(_num)) {

+ 6 - 6
config.js

@@ -1,13 +1,13 @@
 // 测试服
-// const apiUrl = "https://hw.hap-job.com/happy-boot"
-// const baseurl = "https://hw.hap-job.com"
-// const captcha = '2072736870'
+const apiUrl = "https://hw.hap-job.com/happy-boot"
+const baseurl = "https://hw.hap-job.com"
+const captcha = '2072736870'
 // const imgServerUrl = "https://hpjobtest.oss-cn-shanghai.aliyuncs.com/uploadfiles/mina"//图片服务器地址
 // const imgServerUrl_new = "https://hpjobtest.oss-cn-shanghai.aliyuncs.com"//图片服务器地址
 // 正式服
-const apiUrl = "https://www.dal-pay.com/happy-boot"
-const baseurl = "https://www.dal-pay.com"
-const captcha = '2012155849'
+// const apiUrl = "https://www.dal-pay.com/happy-boot"
+// const baseurl = "https://www.dal-pay.com"
+// const captcha = '2012155849'
 // const imgServerUrl = "https://happyjob.oss-cn-shanghai.aliyuncs.com/uploadfiles/mina"//图片服务器地址
 // const imgServerUrl_new = "https://happyjob.oss-cn-shanghai.aliyuncs.com"//图片服务器地址
 

+ 8 - 4
pages/common-setting/common-setting.js

@@ -7,16 +7,18 @@ Page({
    * 页面的初始数据
    */
   data: {
-    version: '',
-    cancellation: false,
-    userAgreement: encodeURIComponent(baseurl + '/uploadfile/userAgreement.html'),
-    privacyPolicy: encodeURIComponent(baseurl + '/uploadfile/privacyPolicy.html')
+    version: '', // 版本号
+    cancellation: false, // 显示注销账号开关
+    userAgreement: encodeURIComponent(baseurl + '/uploadfile/userAgreement.html'), // 用户协议
+    privacyPolicy: encodeURIComponent(baseurl + '/uploadfile/privacyPolicy.html'), // 隐私政策
   },
+  // 显示注销账号弹窗
   showCancellation() {
     this.setData({
       cancellation: !this.data.cancellation
     })
   },
+  // 注销账号
   cancellation() {
     wx.clearStorage({
       success: res => {
@@ -31,6 +33,7 @@ Page({
       }
     })
   },
+  // 退出登录
   logout() {
     wx.clearStorage({
       success: res => {
@@ -44,6 +47,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    // 判断是否有获取账户信息的api 有的话取活的
     if (wx.getAccountInfoSync) {
       const info = wx.getAccountInfoSync()
       this.setData({

+ 12 - 4
pages/detail/detail.js

@@ -1,9 +1,11 @@
 // pages/detail/detail.js
 const app = getApp();
+// 未填写提示字段及信息
 const errorMessage = {
   info_name: '请填写姓名',
   idcardNumber: '请填写身份证号码',
 }
+// 未填写key值
 const errorKey = {
   info_name: 'name_error',
   idcardNumber: 'id_error',
@@ -27,9 +29,9 @@ Page({
       '4': '订单完成'
     },
     status: 0, //按钮状态 1 需求 2 已报名 3 订单
-    show: true,
-    name_error: false,
-    id_error: false,
+    show: true, // 是否展示
+    name_error: false, // 姓名错误信息
+    id_error: false, //  身份证错误信息
     // btn_message: ''
   },
   /**
@@ -66,6 +68,7 @@ Page({
         })
       }
     }
+    // 报名需求
     wx.kx_request({
       url: wx.kx_api.hwRequirement.enrollmentRequire,
       model: true,
@@ -205,10 +208,11 @@ Page({
   /**
    * 确认订单
    * @orderId {string} 订单ID
-   * 前台报名需求后  后台生成订单   需前台手动确定订单
+   * 前台报名需求后  后台生成订单   需前台手动确定订单 根据订单合同不同调用不同接口
    */
   buttonSubmit() {
     const contractType = this.data.hwOrderAPI.contractType;
+    // 电子合同确认订单
     if (contractType === 2) {
       wx.kx_request({
         url: wx.kx_api.hwOrder.confirmECOrders,
@@ -218,9 +222,11 @@ Page({
         },
         success: res => {
           if (res.errcode === 0) {
+            // 跳转webview页面
             wx.reLaunch({
               url: `/pages/web-view/web-view?url=${encodeURIComponent(res.data.url)}`,
               success: res => {
+                // 缓存当前页面地址   方便跳回
                 app.globalData.webview = `/pages/my-order/my-order`;
                 // wx.setStorageSync('web_view', `/pages/my-order/my-order`)
                 // wx.setStorageSync('web_view', `/${this.route}?id=${this.data.hwOrderAPI.id}&&status=${this.data.status}`)
@@ -230,6 +236,7 @@ Page({
         }
       })
     }
+    // 非电子合同
     if (contractType === 1 || contractType === 0) {
       wx.kx_request({
         url: wx.kx_api.hwOrder.confirmOrder,
@@ -255,6 +262,7 @@ Page({
       })
     }
   },
+  // 显示报名填写的订单输入框
   async showCover() {
     const userinfo = await app.utils.getHwUserInfo(this)
     if (userinfo.idcardNumber && userinfo.name) {

+ 2 - 0
pages/login/login.js

@@ -171,6 +171,7 @@ Page({
                   data: res.data.userInfo.userToken,
                   success: data => {
                     wx.setStorageSync('userinfo', res.data.userInfo)
+                    // 提交是否登录信息
                     wx.$emit('is_login', true, () => {
                       wx.navigateBack({
                         delta: 1,
@@ -219,6 +220,7 @@ Page({
    */
   onLoad: function (options) {
     this.options = options;
+    // 监听是否离线
     wx.$watch('offline', this, (value) => {
       if (value) {
         clearInterval(this.setInter)

+ 4 - 0
pages/my-apply/my-apply.js

@@ -50,6 +50,10 @@ Page({
       }
     })
   },
+  /**
+   * 取消订单
+   * @param {id} 订单id   
+   */
   cancelEnrollment(e) {
     const { id } = e.currentTarget.dataset;
     wx.kx_request({

+ 4 - 1
pages/my-order/my-order.js

@@ -50,6 +50,7 @@ Page({
     const index = e.currentTarget.dataset.index;
     const contracttype = e.currentTarget.dataset.contracttype;
     const parentindex = e.currentTarget.dataset.parentindex;
+    // 电子合同确认
     if (contracttype === 2) {
       wx.kx_request({
         url: wx.kx_api.hwOrder.confirmECOrders,
@@ -59,9 +60,11 @@ Page({
         },
         success: res => {
           if (res.errcode === 0) {
+            // 跳转webview
             wx.reLaunch({
               url: `/pages/web-view/web-view?url=${encodeURIComponent(res.data.url)}`,
               success: res => {
+                // 存入缓存方便跳回
                 app.globalData.webview = `/${this.route}`;
                 // wx.setStorageSync('web_view', `/${this.route}`)
               }
@@ -70,7 +73,7 @@ Page({
         }
       })
     }
-
+    // 非电子合同确认
     if (contracttype === 1 || contracttype === 0) {
       wx.kx_request({
         url: wx.kx_api.hwOrder.confirmOrder,

+ 1 - 0
pages/person/person.js

@@ -52,6 +52,7 @@ Page({
       this.setData({
         userinfo: wx.getStorageSync('userinfo'),
       }, _ => {
+        // 监听个人信息变动
         wx.$watch('userinfo', this, (data) => {
 
           this.setData({

+ 1 - 0
pages/userinfo/userinfo.js

@@ -34,6 +34,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function(options) {
+    // 获取个人信息
     app.utils.getHwUserInfo(this)
   },
 

+ 1 - 1
project.config.json

@@ -34,7 +34,7 @@
 	},
 	"compileType": "miniprogram",
 	"libVersion": "2.7.7",
-	"appid": "wxb0f8f3f0de6e8f07",
+	"appid": "wx997164f2857c1a1d",
 	"projectname": "Mina_B",
 	"debugOptions": {
 		"hidedInDevtools": []

+ 2 - 0
utils/config_api.js

@@ -1,5 +1,6 @@
 const api = require('./api')
 module.exports = {
+  // 不需要登录的接口
   dont_login: [
     api.hwuser.getAuthCode,//获取验证码
     api.hwuser.phoneLogin,//手机号登陆
@@ -7,5 +8,6 @@ module.exports = {
     api.hwRequirement.getRequirementDetail,//需求详情
     api.hwRequirement.getRequirements,//需求列表
   ],
+  // 不需要openID的接口  由于openID在本项目不需要特别支持  所以这个接口集合基本废弃
   no_openid: []
 }

+ 5 - 0
utils/util.js

@@ -1,3 +1,8 @@
+/**
+ * 这边主要是为公共请求方法服务的 同时支持回调与promise.then两种获取值的方法
+ * 我本人喜欢回调方法
+ * 如果习惯promise的本方法依旧支持
+ */
 const api = require('./api.js');
 const dont_login_api = require('./config_api.js').dont_login;
 const no_openid_api = require('./config_api.js').no_openid;

+ 21 - 4
utils/watch.js

@@ -1,3 +1,17 @@
+/**
+ * 包含功能:
+ * wx.$get 获取值   wx.$watch 监听值  wx.$emit 提交值 
+ * 
+ * 使用方法:
+ * 普通页面使用方法  在页面onLoad或者onShow里面设置监听   推荐在onLoad监听  onShow会增加额外的变更回调函数开销
+ * 组件中使用方法  在onready中设置监听  
+ * 
+ * 注意事项:
+ * 1、在组件中使用时需手动引入 wx.$behavior 该方法会在组件卸载时自动卸载监听函数 在页面中使用时会在页面卸载时自动移除监听函数  防止抓住页面不放造成小程序卡顿  
+ * 2、如仅仅是需要储存值获取值  不需要实时对在栈中的页面进行操作 推荐使用app.globalData
+ * 3、不建议在基础组件中使用  例如列表组件的子组件  会大量重复渲染推荐使用状态控制  这个方法并没有做优化
+ */
+
 class Watch {
   constructor(that, watchData) {
     //  watch函数回调集合
@@ -84,14 +98,15 @@ class Watch {
       [key]: this.$_watchCallBack[key] || []
     });
     // 判断页面是否存入过该方法  若存入过则更改回调方法  否则推入函数
-    let _index = this.$_watchCallBack[key].findIndex(val => val.name === page.__wxExparserNodeId__);
+    let _index = this.$_watchCallBack[key].findIndex(val => val.name === page.$$PageName);
     if (_index === -1) {
       console.info(`${page.is} watch=>`, key)
       // 添加自动移除的方法
       page = this.$_autoRemove(key, page)
+      page.$$PageName = Symbol("PageName");
       // 推入新的监听事件
       this.$_watchCallBack[key].push({
-        name: page.__wxExparserNodeId__,
+        name: page.$$PageName,
         page,
         cb: callback
       })
@@ -99,16 +114,18 @@ class Watch {
       // 存在则改写回调函数
       this.$_watchCallBack[key][_index].cb = callback;
     }
+    console.log(Symbol("wangxin"))
+    console.log(page)
   }
   /**
    * 移除监听事件
-   * @key {String} 需要移除监听的键值 
+   * @key {String} 需要移除监听的键值
    * @page {Object} 需移除监听的页面
    * @callback {function} 移除监听完成的回调函数
    */
   $_remove(key, page, callback) {
     // 获取索引
-    let _index = this.$_watchCallBack[key].findIndex(val => val.name === page.__wxExparserNodeId__);
+    let _index = this.$_watchCallBack[key].findIndex(val => val.name === page.$$PageName);
     if (_index !== -1) {
       // 移除监听
       let _item = this.$_watchCallBack[key].splice(_index, 1);