洪海涛 8 năm trước cách đây
mục cha
commit
daf12d88b8

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
www/vue/dist/static/js/app.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
www/vue/dist/static/js/vendor.js


+ 1 - 1
www/vue/package.json

@@ -14,7 +14,7 @@
     "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
   },
   "dependencies": {
-    "sass-convert": "^0.5.2",
+    "qs": "^6.4.0",
     "vue": "^2.3.3",
     "vue-awesome-swiper": "^2.4.2",
     "vue-axios": "^2.0.2",

+ 20 - 0
www/vue/src/components/order.vue

@@ -1,12 +1,32 @@
 <template lang="html">
 <div class="order">
   <h2>order</h2>
+  <ul>
+    <li v-for="item in userInfo">{{item.name}}</li>
+  </ul>
 </div>
 </template>
 
 <script>
+import { mapState, mapActions } from 'vuex'
+
 export default {
+  computed: mapState({
+    userInfo: state => state.userInfo
+  }),
+  created () {
+    this.USERINFO()
+    console.log(this)
+  },
+  methods: {
+    ...mapActions([
+      'USERINFO'
+    ])
+  }
 }
+console.log(1)
+console.log(this.$store.state.userInfo)
+console.log(2)
 </script>
 
 <style lang="css">

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

@@ -13,6 +13,9 @@ export default {
     }
   }
 }
+
+console.log(this.$store)
+
 </script>
 
 <!-- Add "scoped" attribute to limit CSS to this component only -->

+ 13 - 33
www/vue/src/config/api.js

@@ -1,49 +1,29 @@
 import axios from 'axios'
+import config from './config'
 // let apiPath = 'http://commontest.yiguanjia.me/index.php?r='
-let apiPath = ''
-let uri = location.href
-let test = true
-var userId = ''
-var formData = new FormData()
-
-if (uri.indexOf('common.yiguanjia.me') > -1) {
-  test = false
-}
-// 正式开发判断test还是pro
-if (test) {
-  apiPath = 'http://commontest.yiguanjia.me/index.php?r='
-  userId = localStorage.getItem('wxUserID')
-} else {
-  apiPath = 'http://common.yiguanjia.me/index.php?r='
-  userId = localStorage.getItem('wxUserID')
-}
-// 判断是否为dev开发
-if (uri.indexOf('http://localhost:8080/') > -1) {
-  apiPath = ''
-  userId = '57e238929f5160d6048b456d'
-} else if (uri.indexOf('common.yiguanjiadev.me') > -1) {
-  apiPath = 'http://common.yiguanjiadev.me/index.php?r='
-  userId = '57e238929f5160d6048b456d'
-}
-formData.append('user_id', userId)
-console.log(formData)
-export default({
+console.log(config)
+console.log(config.formData)
+export default ({
   // 获取用户信息
   getO2oUserInfo: function (cb) {
-    axios.post(apiPath + 'o2o/user/info', formData).then(function (res) {
+    console.log(config.userId)
+    axios.post('o2o/user/info', config.formData).then(function (res) {
+      console.log(res.data)
       cb(res.data)
     })
   },
   // 获取商品列表
   getProductList: function (cb) {
-    axios.get(apiPath + 'o2o/product/list').then(function (res) {
+    axios.get('o2o/product/list').then(function (res) {
       cb(res.data)
     })
   },
-  // 充值卡支付
-  getPayCharge: function (data, cb) {
-    axios.get(apiPath + 'o2o/recharge/payRecharge', formData + data).then(function (res) {
+  // 充值卡支付状态获取
+  getPayCharge: function (cb, data) {
+    axios.get('o2o/recharge/payRecharge', config.formData).then(function (res) {
       cb(res.data)
+    }).catch(function (error) {
+      console.log(error)
     })
   }
 })

+ 33 - 0
www/vue/src/config/config.js

@@ -0,0 +1,33 @@
+import axios from 'axios'
+let apiPath = ''
+let uri = location.href
+let test = true
+var userId = ''
+var formData = new FormData()
+if (uri.indexOf('common.yiguanjia.me') > -1) {
+  test = false
+}
+// 正式开发判断test还是pro
+if (test) {
+  apiPath = 'http://commontest.yiguanjia.me/index.php?r='
+  userId = localStorage.getItem('wxUserID')
+} else {
+  apiPath = 'http://common.yiguanjia.me/index.php?r='
+  userId = localStorage.getItem('wxUserID')
+}
+// 判断是否为dev开发
+if (uri.indexOf('http://localhost:8080/') > -1) {
+  apiPath = ''
+  userId = '57e238929f5160d6048b456d'
+} else if (uri.indexOf('common.yiguanjiadev.me') > -1) {
+  apiPath = 'http://common.yiguanjiadev.me/index.php?r='
+  userId = '57e238929f5160d6048b456d'
+}
+
+axios.defaults.baseURL = apiPath
+axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
+formData.append('user_id', userId)
+export default {
+  userId: userId,
+  formData: formData
+}

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

@@ -12,6 +12,7 @@ Vue.config.productionTip = false
 Vue.use(VueRouter)
 // axios.defaults.baseURL = '/o2o'
 /* eslint-disable no-new */
+
 import VueAwesomeSwiper from 'vue-awesome-swiper'
 Vue.use(VueAwesomeSwiper)
 

+ 1 - 1
www/vue/src/store/test.js

@@ -10,7 +10,7 @@ export default {
   mutations: {
     // 注意,这里可以设置 state 属性,但是不能异步调用,异步操作写到 actions 中
     USERINFO (state, userInfo) {
-      state.userInfo = userInfo
+      state.userInfo = userInfo.data
     }
   },
   actions: {

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác