洪海涛 8 سال پیش
والد
کامیت
2149df6069

+ 5 - 6
www/vue/src/components/home.vue

@@ -22,28 +22,27 @@
     name: 'home',
     data () {
       return {
-        msg: 'Welcome to Your Vue.js App',
         homeImg1: 'http://odulvej8l.bkt.clouddn.com/%E5%9B%BE%E6%A0%87-01.jpg'
       }
     },
     computed: mapState({
-      userInfo: state => state.userInfo
+      userInfo: state => state.userInfo,
+      productInfo: state => state.product.productInfo
     }),
     created () {
-      this.PRODUCTLIST()
       this.USERINFO()
-      console.log(this.$store.state.product.products)
+      this.PRODUCT()
     },
     methods: {
       ...mapActions([
         'USERINFO',
-        'PRODUCTLIST'
+        'PRODUCT'
       ])
     }
   }
 </script>
 
-<!-- Add "scoped" attribute to limit CSS to this component only -->
+<!-- 添加“scoped”属性来限制CSS到此组件 -->
 <style scoped>
   .home-img-1 {
     background-color: #fff;

+ 10 - 8
www/vue/src/components/homeList.vue

@@ -1,5 +1,6 @@
 <template>
   <div class="home-list">
+    <!--<button @click="btn">调试</button>-->
     <ul>
       <li v-for="items in productIcon" v-on:click="pro(items.id)">
         <div class="product-icon" :style="{backgroundColor:items.color}">
@@ -15,26 +16,27 @@
 
 <script>
   import config from '../config/config'
+  import product from '../config/product'
   export default {
     name: 'home',
     data () {
       return {
-        productIcon: config.productIcon
+        productIcon: product.productIcon
       }
     },
     created () {
-      for (let i in config.productIcon) {
-        console.log(config.productIcon[i])
-        console.log(this.$store.state.product.products)
-      }
+      console.log(this.$store.state)
     },
     methods: {
+      btn: function () {
+        console.log(this.$store.state.product)
+      },
       pro: function (id) {
         config.productInfo = {}
         let products = this.$store.state.product.products
         for (let i in products) {
-          if (products[i].id === id) {
-            config.productInfo = products[i]
+          if (this.$store.state.product.productIcon[i].id === id) {
+            config.productInfo = this.$store.state.product.productIcon[i]
           }
         }
         // 带查询参数,变成 /register?plan=private
@@ -44,7 +46,7 @@
   }
 </script>
 
-<!-- Add "scoped" attribute to limit CSS to this component only -->
+<!-- 添加“scoped”属性来限制CSS到此组件 -->
 <style scoped>
   .home-list {
     margin-top: 3%;

+ 0 - 1
www/vue/src/components/product.vue

@@ -85,7 +85,6 @@
         }
         config.orderInfo = tmp
         this.PAYCHANGE()
-        console.log(time)
       },
       btnAction: function (index) {
         this.isActive = index

+ 7 - 7
www/vue/src/config/api.js

@@ -82,13 +82,13 @@ export default ({
 
             let prepay = option['package'].replace('prepay_id=', '')
             window.location.href = 'http://common.yiguanjia.me/webapp/o2o/module/pay/index.html?appId=' +
-                option.appId + '&nonceStr=' + option.nonceStr +
-                '&package=' + prepay + '&signType=' +
-                option.signType + '&timeStamp=' +
-                option.timeStamp + '&paySign=' +
-                option.paySign + '&amount=' + wxPay.amount +
-                '&created=' + wxPay.created + '&body=' +
-                wxPay.body + '&bookingTime=' + bookingTime
+              option.appId + '&nonceStr=' + option.nonceStr +
+              '&package=' + prepay + '&signType=' +
+              option.signType + '&timeStamp=' +
+              option.timeStamp + '&paySign=' +
+              option.paySign + '&amount=' + wxPay.amount +
+              '&created=' + wxPay.created + '&body=' +
+              wxPay.body + '&bookingTime=' + bookingTime
           }
         }).catch(function (e) {
           console.log(e)

+ 4 - 55
www/vue/src/config/config.js

@@ -5,8 +5,8 @@ let test = true
 let userId = ''
 let formData = ''
 let orderInfo = []
-let productInfo = {}
-let productIcon = []
+let productInfo = []
+
 if (uri.indexOf('common.yiguanjia.me') > -1) {
   test = false
 }
@@ -27,64 +27,13 @@ if (uri.indexOf('http://localhost:8080/') > -1) {
   userId = '57e38f1b9f5160ac048b457d'
 }
 
-productIcon = [
-  {
-    name: '母婴清洁',
-    id: '57e3a5a49f5160c9048b457c',
-    url: 'http://oduj3utzz.bkt.clouddn.com/home-mother-child.png',
-    color: '#a6dc48'
-  },
-  {
-    name: '日常清洁',
-    id: '57e0dffc9f5160dd048b4568',
-    url: 'http://oduj3utzz.bkt.clouddn.com/home-daily.png',
-    color: '#76a6f6'
-  },
-  {
-    name: '深度清洁',
-    id: '57e0e0189f5160dc048b4568',
-    url: 'http://oduj3utzz.bkt.clouddn.com/home-depth.png',
-    color: '#5ecdec'
-  },
-  {
-    name: '专业除螨',
-    id: '57e0e0369f5160b1048b456b',
-    url: 'http://oduj3utzz.bkt.clouddn.com/home-mites.png',
-    color: '#b17ff6'
-  },
-  {
-    name: '家电清洗',
-    url: 'http://oduj3utzz.bkt.clouddn.com/home-appliances.png',
-    id: '57e0e04e9f5160af048b456b',
-    color: '#fabf4c'
-  },
-  {
-    name: '新居开荒',
-    id: '57e0e0879f5160b8048b4571',
-    url: 'http://oduj3utzz.bkt.clouddn.com/home-new-home.png',
-    color: '#5adde9'
-  },
-  {
-    name: '擦玻璃',
-    id: '57fb4a909f5160b2048b4a0e',
-    url: 'http://oduj3utzz.bkt.clouddn.com/home-ca-bo-li.png',
-    color: '#70df68'
-  },
-  {
-    name: '租房大扫除',
-    id: '5851fb3b9f5160c5048b6412',
-    url: 'http://oduj3utzz.bkt.clouddn.com/home-renting.png',
-    color: '#fcac71'
-  }
-]
-
 axios.defaults.baseURL = apiPath
 axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
+
 export default {
   userId: userId,
   formData: formData,
   orderInfo: orderInfo,
   test: test,
-  productInfo: productInfo,
-  productIcon: productIcon
+  productInfo: productInfo
 }

+ 54 - 0
www/vue/src/config/product.js

@@ -0,0 +1,54 @@
+const productIcon = [
+  {
+    name: '母婴清洁',
+    url: 'http://oduj3utzz.bkt.clouddn.com/home-mother-child.png',
+    color: '#a6dc48',
+    id: ''
+  },
+  {
+    name: '日常清洁',
+    url: 'http://oduj3utzz.bkt.clouddn.com/home-daily.png',
+    color: '#76a6f6',
+    id: ''
+  },
+  {
+    name: '深度清洁',
+    url: 'http://oduj3utzz.bkt.clouddn.com/home-depth.png',
+    color: '#5ecdec',
+    id: ''
+  },
+  {
+    name: '专业除螨',
+    url: 'http://oduj3utzz.bkt.clouddn.com/home-mites.png',
+    color: '#b17ff6',
+    id: ''
+  },
+  {
+    name: '家电清洗',
+    url: 'http://oduj3utzz.bkt.clouddn.com/home-appliances.png',
+    color: '#fabf4c',
+    id: ''
+  },
+  {
+    name: '新居开荒',
+    url: 'http://oduj3utzz.bkt.clouddn.com/home-new-home.png',
+    color: '#5adde9',
+    id: ''
+  },
+  {
+    name: '擦玻璃',
+    url: 'http://oduj3utzz.bkt.clouddn.com/home-ca-bo-li.png',
+    color: '#70df68',
+    id: ''
+  },
+  {
+    name: '租房大扫除',
+    url: 'http://oduj3utzz.bkt.clouddn.com/home-renting.png',
+    color: '#fcac71',
+    id: ''
+  }
+]
+
+export default {
+  productIcon: productIcon
+}

+ 0 - 1
www/vue/src/main.js

@@ -13,7 +13,6 @@ Vue.use(VueAxios, axios)
 Vue.config.productionTip = false
 Vue.use(VueRouter)
 Vue.use(VueAwesomeSwiper)
-
 const router = new VueRouter({
   mode: 'history',
   routes

+ 3 - 4
www/vue/src/store/index.js

@@ -4,16 +4,15 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
 import user from './user'
-import product from './product'
 import PayCharge from './PayCharge'
-//  import orderChange from './orderChange'
 import order from './order'
+import product from './product'
 Vue.use(Vuex)
 export default new Vuex.Store({
   modules: {
     user,
-    product,
     PayCharge,
-    order
+    order,
+    product
   }
 })

+ 23 - 9
www/vue/src/store/product.js

@@ -1,21 +1,35 @@
-/**
- * Created by north on 2017/6/15.
- */
 import api from '../config/api'
-
+import product from '../config/product'
 export default {
   state: {
-    products: {}
+    products: [],
+    productIcon: []
   },
   mutations: {
-    PRODUCTLIST (state, products) {
-      state.products = products
+    PRODUCT (state, pro) {
+      state.products = pro.res.data
+      state.productIcon = pro.productIcon
     }
   },
   actions: {
-    PRODUCTLIST ({commit}) {
+    PRODUCT ({commit}) {
+      let productB = true
       api.getProductList(function (res) {
-        commit('PRODUCTLIST', res.data.products)
+        if (productB) {
+          for (let i in product.productIcon) {
+            if ((product.productIcon[i].name).substring(0, 2) === (res.data.products[i].name).substring(0, 2)) {
+              product.productIcon[i].id = res.data.products[i].id
+              product.productIcon[i].name = res.data.products[i].name
+            }
+          }
+          productB = false
+        }
+        let productIcon = product.productIcon
+        let pro = {
+          res,
+          productIcon
+        }
+        commit('PRODUCT', pro)
       })
     }
   }