Browse Source

scg地址编辑

honghaitzz11 6 years ago
parent
commit
59b069faa4

File diff suppressed because it is too large
+ 0 - 0
www/webapp/scg/asset/css/app.css


File diff suppressed because it is too large
+ 0 - 0
www/webapp/scg/asset/css/app.css.map


File diff suppressed because it is too large
+ 0 - 0
www/webapp/scg/asset/js/app.js


File diff suppressed because it is too large
+ 0 - 0
www/webapp/scg/asset/js/app.js.map


File diff suppressed because it is too large
+ 0 - 0
www/webapp/scg/asset/js/manifest.js.map


File diff suppressed because it is too large
+ 0 - 0
www/webapp/scg/asset/js/vendor.js


File diff suppressed because it is too large
+ 0 - 0
www/webapp/scg/asset/js/vendor.js.map


+ 279 - 0
www/webapp/scg/src/lib/util.js

@@ -0,0 +1,279 @@
+export default {
+  /**
+   * Determine if a value is an Array
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is an Array, otherwise false
+   */
+  isArray(val) {
+    return toString.call(val) === '[object Array]';
+  },
+  /**
+   * Determine if a value is an ArrayBuffer
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is an ArrayBuffer, otherwise false
+   */
+  isArrayBuffer(val) {
+    return toString.call(val) === '[object ArrayBuffer]';
+  },
+  /**
+   * Determine if a value is a FormData
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is an FormData, otherwise false
+   */
+  isFormData(val) {
+    return (typeof FormData !== 'undefined') && (val instanceof FormData);
+  },
+  /**
+   * Determine if a value is a view on an ArrayBuffer
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
+   */
+  isArrayBufferView(val) {
+    let result;
+    if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
+      result = ArrayBuffer.isView(val);
+    } else {
+      result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
+    }
+    return result;
+  },
+  /**
+   * Determine if a value is a String
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is a String, otherwise false
+   */
+  isString(val) {
+    return typeof val === 'string';
+  },
+  /**
+   * Determine if a value is a Number
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is a Number, otherwise false
+   */
+  isNumber(val) {
+    return typeof val === 'number';
+  },
+  /**
+   * Determine if a value is undefined
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if the value is undefined, otherwise false
+   */
+  isUndefined(val) {
+    return typeof val === 'undefined';
+  },
+  /**
+   * Determine if a value is an Object
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is an Object, otherwise false
+   */
+  isObject(val) {
+    return val !== null && typeof val === 'object';
+  },
+  /**
+   * Determine if a value is a Date
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is a Date, otherwise false
+   */
+  isDate(val) {
+    return toString.call(val) === '[object Date]';
+  },
+  /**
+   * Determine if a value is a File
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is a File, otherwise false
+   */
+  isFile(val) {
+    return toString.call(val) === '[object File]';
+  },
+  /**
+   * Determine if a value is a Blob
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is a Blob, otherwise false
+   */
+  isBlob(val) {
+    return toString.call(val) === '[object Blob]';
+  },
+  /**
+   * Determine if a value is a Function
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is a Function, otherwise false
+   */
+  isFunction(val) {
+    return toString.call(val) === '[object Function]';
+  },
+  /**
+   * Determine if a value is a Stream
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is a Stream, otherwise false
+   */
+  isStream(val) {
+    return this.isObject(val) && this.isFunction(val.pipe);
+  },
+  /**
+   * Determine if a value is a URLSearchParams object
+   *
+   * @param {Object} val The value to test
+   * @returns {boolean} True if value is a URLSearchParams object, otherwise false
+   */
+  isURLSearchParams(val) {
+    return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
+  },
+  /**
+   * Trim excess whitespace off the beginning and end of a string
+   *
+   * @param {String} str The String to trim
+   * @returns {String} The String freed of excess whitespace
+   */
+  trim(str) {
+    return str.replace(/^\s*/, '')
+    .replace(/\s*$/, '');
+  },
+  /**
+   * Determine if we're running in a standard browser environment
+   *
+   * This allows axios to run in a web worker, and react-native.
+   * Both environments support XMLHttpRequest, but not fully standard globals.
+   *
+   * web workers:
+   *  typeof window -> undefined
+   *  typeof document -> undefined
+   *
+   * react-native:
+   *  navigator.product -> 'ReactNative'
+   */
+  isStandardBrowserEnv() {
+    if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
+      return false;
+    }
+    return (
+      typeof window !== 'undefined' &&
+      typeof document !== 'undefined'
+    );
+  },
+  /**
+   * Iterate over an Array or an Object invoking a function for each item.
+   *
+   * If `obj` is an Array callback will be called passing
+   * the value, index, and complete array for each item.
+   *
+   * If 'obj' is an Object callback will be called passing
+   * the value, key, and complete object for each property.
+   *
+   * @param {Object|Array} obj The object to iterate
+   * @param {Function} fn The callback to invoke for each item
+   */
+  forEach(obj, fn) {
+    // Don't bother if no value provided
+    if (obj === null || typeof obj === 'undefined') {
+      return;
+    }
+    // Force an array if not already something iterable
+    if (typeof obj !== 'object') {
+      /* eslint no-param-reassign:0 */
+      obj = [obj];
+    }
+    if (this.isArray(obj)) {
+      // Iterate over array values
+      for (let i = 0, l = obj.length; i < l; i += 1) {
+        fn.call(null, obj[i], i, obj);
+      }
+    } else {
+      // Iterate over object keys
+      // eslint-disable-next-line
+      for (const key in obj) {
+        if (Object.prototype.hasOwnProperty.call(obj, key)) {
+          fn.call(null, obj[key], key, obj);
+        }
+      }
+    }
+  },
+  /**
+   * Accepts varargs expecting each argument to be an object, then
+   * immutably merges the properties of each object and returns result.
+   *
+   * When multiple objects contain the same key the later object in
+   * the arguments list will take precedence.
+   *
+   * Example:
+   *
+   * ```js
+   * var result = merge({foo: 123}, {foo: 456});
+   * console.log(result.foo); // outputs 456
+   * ```
+   *
+   * @param {Object} obj1 Object to merge
+   * @returns {Object} Result of all merge properties
+   */
+  merge(/* obj1, obj2, obj3, ... */) {
+    const result = {};
+
+    function assignValue(val, key) {
+      if (typeof result[key] === 'object' && typeof val === 'object') {
+        result[key] = this.merge(result[key], val);
+      } else {
+        result[key] = val;
+      }
+    }
+
+    for (let i = 0, l = arguments.length; i < l; i += 1) {
+      // eslint-disable-next-line
+      this.forEach(arguments[i], assignValue);
+    }
+    return result;
+  },
+  /**
+   * Extends object a by mutably adding to it the properties of object b.
+   *
+   * @param {Object} a The object to be extended
+   * @param {Object} b The object to copy properties from
+   * @param {Object} thisArg The object to bind function to
+   * @return {Object} The resulting value of object a
+   */
+  extend(a, b, thisArg) {
+    function assignValue(val, key) {
+      if (thisArg && typeof val === 'function') {
+        a[key] = this.bind(val, thisArg);
+      } else {
+        a[key] = val;
+      }
+    }
+
+    this.forEach(b, assignValue);
+    return a;
+  },
+  bind(fn, thisArg) {
+    return function wrap() {
+      const args = new Array(arguments.length);
+      for (let i = 0; i < args.length; i += 1) {
+        // eslint-disable-next-line
+        args[i] = arguments[i];
+      }
+      return fn.apply(thisArg, args);
+    };
+  },
+  /**
+   * 检测当前系统会否属于测试环境
+   * @return {Boolean} true 为测试环境;false 为生产环境
+   * */
+  isDev() {
+    const url = location.href;
+    let dev = false;
+    if (url.indexOf('common.yiguanjia.me') < 0) {
+      dev = true;
+    }
+    return dev;
+  }
+};

+ 68 - 44
www/webapp/scg/src/store.js

@@ -3,9 +3,8 @@ import Vuex from 'vuex';
 import http from 'api';
 import ApiSetting from 'lib/baseUrl';
 import userID from 'lib/userID';
-import isDev from 'lib/isDev';
+import util from 'lib/util';
 import Name from 'lib/name';
-import product from 'lib/product';
 import {
   createAPI, Dialog
 } from 'cube-ui';
@@ -18,7 +17,7 @@ Vue.use(Vuex);
 export default new Vuex.Store({
   state: {
     user_id: userID(),
-    isDev: isDev(),
+    isDev: util.isDev(),
     userInfo: {},
     ifLogin: '',
     name: Name,
@@ -38,42 +37,67 @@ export default new Vuex.Store({
       http(ApiSetting.GetUserInfo, {
         user_id: state.user_id
       })
+      .then(res => {
+        // eslint-disable-next-line
+        self.userInfo = res;
+        if (self.userInfo.avatar.indexOf('odulcd8g1.bkt.clouddn.com')) {
+          self.userInfo.avatar = self.userInfo.avatar.replace(/odulcd8g1\.bkt\.clouddn\.com/, 'avatar.yiguanjia.me');
+        }
+      })
+      .then(() => {
+        if (self.userInfo.source === '建工' && self.userInfo.user_info.phone !== '' && self.userInfo.type === '微信') {
+          self.ifLogin = false;
+        } else {
+          self.ifLogin = true;
+        }
+      })
+      .then(() => {
+        // console.log('准备获取商品列表');
+        // self.productList = product.data.products;
+        http(ApiSetting.getProductList)
         .then(res => {
-          // eslint-disable-next-line
-          self.userInfo = res;
-          if (self.userInfo.avatar.indexOf('odulcd8g1.bkt.clouddn.com')) {
-            self.userInfo.avatar = self.userInfo.avatar.replace(/odulcd8g1\.bkt\.clouddn\.com/, 'avatar.yiguanjia.me');
-          }
-        })
-        .then(() => {
-          if (self.userInfo.source === '建工' && self.userInfo.user_info.phone !== '' && self.userInfo.type === '微信') {
-            self.ifLogin = false;
-          } else {
-            self.ifLogin = true;
-          }
-        })
-        .then(() => {
-          console.log('准备获取商品列表');
-          self.productList = product.data.products;
-          // http(ApiSetting.getProductList)
-          //   .then(res => {
-          //     console.log(res);
-          //     const products = {};
-          //     res.products.forEach((key, i) => {
-          //       products[i] = key;
-          //       products[i].pics.forEach((p, index) => {
-          //         // products[i].pics[index] = products[i].pics[index].url.replace(/oduj3utzz\.bkt\.clouddn\.com/, 'icon.yiguanjia.me');
-          //         products[i].pics[index].url = products[i].pics[index].url.replace(/oduj3utzz\.bkt\.clouddn\.com/, 'icon.yiguanjia.me');
-          //       });
-          //     });
-          //     self.productList = products;
-          //   });
+          console.log(res);
+          const products = {};
+          res.products.forEach((key, i) => {
+            products[i] = key;
+            products[i].pics.forEach((p, index) => {
+              products[i].pics[index].url = products[i].pics[index].url.replace(/oduj3utzz\.bkt\.clouddn\.com/, 'icon.yiguanjia.me');
+            });
+          });
+          self.productList = products;
         });
+      });
     },
     addOrder(state) {
+      // 检测用户地址是否在服务范围内
+      // http(ApiSetting.checkAddress, {
+      //   user_id: this.$store.state.userInfo.id,
+      //   address_id: this.order.address.address_id
+      // })
+      //   .then(res=>{
+      //
+      //   })
       console.log(state.order);
       console.log(state.userInfo);
       console.log(state.product);
+      const json = {
+        balance: state.userInfo.balance,
+        products: JSON.stringify({
+          product_id: state.product.id,
+          count: state.order.num
+        }),
+        memo: state.order.remarks !== undefined ? state.order.remarks : '',
+        precedence: '0',
+        booking_time: `${state.order.time.other.selectedVal[0]}-${state.order.time.other.selectedVal[1]}-${state.order.time.other.selectedVal[2]} ${state.order.time.other.selectedVal[3] === 9 ? '09' : state.order.time.other.selectedVal[3]}:00`,
+        address_id: state.order.address.address_id,
+        station: state.order.station,
+        type: state.product.type,
+        counts: state.order.num,
+        extra: `[${JSON.stringify(state.order.active.extra)}]`,
+        order_channel: 'wx_pub',
+        user_id: ''
+      };
+      console.log(json);
       /* http(ApiSetting.addOrder,{
         balance: state.userInfo.balance,
         products: JSON.stringify({
@@ -105,9 +129,9 @@ export default new Vuex.Store({
         address_position: JSON.stringify(that.addressInformation.addressPosition),
         address: JSON.stringify(that.addressInformation.addressDetail)
       })
-        .then(() => {
-          this.commit('dialog', '地址添加成功!');
-        });
+      .then(() => {
+        this.commit('dialog', '地址添加成功!');
+      });
     },
     editAddress(state) {
       const that = state;
@@ -120,9 +144,9 @@ export default new Vuex.Store({
         address_position: JSON.stringify(that.addressInformation.addressPosition),
         address: JSON.stringify(that.addressInformation.addressDetail)
       })
-        .then(() => {
-          this.commit('dialog', '地址编辑成功!');
-        });
+      .then(() => {
+        this.commit('dialog', '地址编辑成功!');
+      });
     },
     delAddress(state) {
       const that = state;
@@ -131,9 +155,9 @@ export default new Vuex.Store({
         request_from: 'weixin',
         address_id: that.addressInformation.address_id
       })
-        .then(() => {
-          this.commit('dialog', '地址删除成功!');
-        });
+      .then(() => {
+        this.commit('dialog', '地址删除成功!');
+      });
     },
     pay(state) {
       const that = state;
@@ -142,9 +166,9 @@ export default new Vuex.Store({
         order_id: that.order.order_id,
         pay_channel: 'wx_pub'
       })
-        .then(res => {
-          console.log(res);
-        });
+      .then(res => {
+        console.log(res);
+      });
     },
     dialog(state, msg) {
       this.dispatch('getUserInfo');

+ 10 - 9
www/webapp/scg/src/views/home/list.vue

@@ -66,15 +66,16 @@
     },
     methods: {
       toProduct(info) {
-        Object.keys(this.$store.state.productList)
-          .forEach(key => {
-            if (this.$store.state.productList[key].name === info.title) {
-              this.$store.state.product = this.$store.state.productList[key];
-            }
-          });
-        // console.log(this.$store.state.product);
-        this.$store.state.order = {};
-        this.$router.push({ name: 'product' });
+        console.log(info);
+        // Object.keys(this.$store.state.productList)
+        //   .forEach(key => {
+        //     if (this.$store.state.productList[key].name === info.title) {
+        //       this.$store.state.product = this.$store.state.productList[key];
+        //     }
+        //   });
+        // // console.log(this.$store.state.product);
+        // this.$store.state.order = {};
+        // this.$router.push({ name: 'product' });
       }
     }
   };

+ 20 - 15
www/webapp/scg/src/views/mine/index.vue

@@ -3,6 +3,7 @@
     <div class="avatar" v-if="userInfo.user_info &&  userInfo.user_info.name">
       <img :src="userInfo.avatar" alt="">
       <div>{{userInfo.user_info.name}}</div>
+      <div class="balance">余额:{{userInfo.balance}}</div>
     </div>
     <div class="mine-list-content border-top-1px">
       <div v-for="(item,index) in userLists" :key="index" class="mine-list border-bottom-1px" @click="other(item)">
@@ -27,21 +28,21 @@
             icon: 'icon-address',
             value: 'address'
           },
-          {
-            label: '用户余额',
-            icon: 'icon-balance',
-            value: 'balanceLog'
-          },
-          {
-            label: '代金券',
-            icon: 'icon-voucher',
-            value: 'userCoupon'
-          },
-          {
-            label: '关于',
-            icon: 'icon-about',
-            value: 'about'
-          }
+          // {
+          //   label: '用户余额',
+          //   icon: 'icon-balance',
+          //   value: 'balanceLog'
+          // },
+          // {
+          //   label: '代金券',
+          //   icon: 'icon-voucher',
+          //   value: 'userCoupon'
+          // },
+          // {
+          //   label: '关于',
+          //   icon: 'icon-about',
+          //   value: 'about'
+          // }
         ]
       };
     },
@@ -77,6 +78,10 @@
       & > div
         color white
         margin-top 1em
+      .balance
+        /*text-align right*/
+        /*padding-right: 15px*/
+        font-size otherSize
     .mine-list
       text-align left
       height: 40px

+ 32 - 28
www/webapp/scg/src/views/order/addOrder.vue

@@ -207,27 +207,31 @@
             user_id: this.$store.state.userInfo.id,
             address_id: this.order.address.address_id
           })
-            .then(res => {
-              this.$store.state.order.station = res.station;
-              const state = this.$store.state;
-              console.log(state.order);
-              console.log(state.userInfo);
-              console.log(state.product);
-              const json = {
-                balance: state.userInfo.balance,
-                products: JSON.stringify({
-                  product_id: state.product.id,
-                  count: state.order.num
-                }),
-                memo: state.order.remarks !== undefined ? state.order.remarks : '',
-                precedence: '0',
-                booking_time: `${state.order.time.other.selectedVal[0]}-${state.order.time.other.selectedVal[1]}-${state.order.time.other.selectedVal[2]} ${state.order.time.other.selectedVal[3] === 9 ? '09' : state.order.time.other.selectedVal[3]}:00`,
-                address_id: state.order.address.address_id,
-                station: state.order.station,
-                type: state.product.type
-              };
-              console.log(json);
-            });
+          .then(res => {
+            this.$store.state.order.station = res.station;
+            const state = this.$store.state;
+            console.log(state.order);
+            console.log(state.userInfo);
+            console.log(state.product);
+            const json = {
+              balance: state.userInfo.balance,
+              products: JSON.stringify({
+                product_id: state.product.id,
+                count: state.order.num
+              }),
+              memo: state.order.remarks !== undefined ? state.order.remarks : '',
+              precedence: '0',
+              booking_time: `${state.order.time.other.selectedVal[0]}-${state.order.time.other.selectedVal[1]}-${state.order.time.other.selectedVal[2]} ${state.order.time.other.selectedVal[3] === 9 ? '09' : state.order.time.other.selectedVal[3]}:00`,
+              address_id: state.order.address.address_id,
+              station: state.order.station,
+              type: state.product.type,
+              counts: state.order.num,
+              extra: `[${JSON.stringify(state.order.active.extra)}]`,
+              order_channel: 'wx_pub',
+              user_id: ''
+            };
+            console.log(json);
+          });
           /* {
         balance: state.userInfo.balance,
         products: JSON.stringify({
@@ -247,7 +251,7 @@
         user_id: userID,
         order_channel: channel
       } */
-          // this.$store.dispatch('addOrder');
+          this.$store.dispatch('addOrder');
         }
       },
       // 选择时间
@@ -289,7 +293,7 @@
             content: '我们的服务时间为早上9点到晚上7点,其他时间段暂不提供服务!',
             time: 2500
           })
-            .show();
+          .show();
           return;
         }
         this.time.text = `${selectedText[0]}${selectedText[1]}${selectedText[2]}${selectedText[3]}`;
@@ -303,7 +307,7 @@
           txt: '取消时间选择',
           time: 1000
         })
-          .show();
+        .show();
       },
       // 订单检测
       orderTest() {
@@ -315,7 +319,7 @@
             content: '你还没有选择服务类型!',
             time: 2500
           })
-            .show();
+          .show();
           return false;
         }
         // 商品数量不为0
@@ -326,7 +330,7 @@
             content: '你还没有选择服务数量!',
             time: 2500
           })
-            .show();
+          .show();
           return false;
         }
         // 时间必选
@@ -337,7 +341,7 @@
             content: '请选择上门服务时间!',
             time: 2500
           })
-            .show();
+          .show();
           return false;
         }
         // 地址不为空
@@ -348,7 +352,7 @@
             content: '您还没有选择地址',
             time: 2500
           })
-            .show();
+          .show();
           return false;
         }
         return true;

Some files were not shown because too many files changed in this diff