north 8 years ago
parent
commit
ee860a2fee

+ 1 - 2
www/vue/config/index.js

@@ -1,7 +1,6 @@
 // see http://vuejs-templates.github.io/webpack for documentation.
 var path = require('path')
-apiPath = 'http://admin.yiguanjiadev.me'
-//apiPath = 'http://api.yiguanjia.me'
+apiPath = 'http://api.yiguanjia.me'
 module.exports = {
   build: {
     env: require('./prod.env'),

File diff suppressed because it is too large
+ 0 - 0
www/vue/dist/static/js/app.js


File diff suppressed because it is too large
+ 0 - 1
www/vue/dist/static/js/vendor.js


+ 8 - 3
www/vue/src/components/swiper.vue

@@ -1,20 +1,25 @@
 <template>
 	<div class="nav">
 		<h1>swiper</h1>
+	  <ul>
+			<li v-for="item in products" >
+				{{item.name}}
+			</li>
+		</ul>
 	</div>
 </template>
 <script type="text/javascript">
   import { mapState, mapActions } from 'vuex'
   export default({
     computed: mapState({
-      userInfo: state => state.test.userInfo
+      products: state => state.product.products
     }),
     created () {
-      this.USERINFO()
+      this.PRODUCTLIST()
     },
     methods: {
       ...mapActions([
-        'USERINFO'
+        'PRODUCTLIST'
       ])
     }
   })

+ 10 - 5
www/vue/src/config/api.js

@@ -1,14 +1,19 @@
 import axios from 'axios'
-
+let apiPath = 'http://apitest.yiguanjia.me/index.php?r='
+// let apiPath = ''
 var formData = new FormData()
 formData.append('user_id', '57e238929f5160d6048b456d')
 export default({
   // 获取用户信息
 
-  getO2oUserInfo: function () {
-    axios.post('o2o/user/info', formData).then((response) => {
-      console.log(response.data)
-      return response.data
+  getO2oUserInfo: function (cb) {
+    axios.post(apiPath + 'o2o/user/info', formData).then(function (res) {
+      cb(res.data)
+    })
+  },
+  getProductList: function (cb) {
+    axios.get(apiPath + 'o2o/product/list').then(function (res) {
+      cb(res.data)
     })
   }
 })

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

@@ -4,9 +4,11 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
 import test from './test'
+import product from './product'
 Vue.use(Vuex)
 export default new Vuex.Store({
   modules: {
-    test
+    test,
+    product
   }
 })

+ 20 - 0
www/vue/src/store/product.js

@@ -1,3 +1,23 @@
 /**
  * Created by north on 2017/6/15.
  */
+import api from '../config/api'
+
+export default {
+  state: {
+    products: {}
+  },
+  mutations: {
+    PRODUCTLIST (state, products) {
+      state.products = products
+      console.log(state.products)
+    }
+  },
+  actions: {
+    PRODUCTLIST ({commit}) {
+      api.getProductList(function (res) {
+        commit('PRODUCTLIST', res.data.products)
+      })
+    }
+  }
+}

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

@@ -16,7 +16,9 @@ export default {
   actions: {
     USERINFO ({commit}) {
       // 获取详情,并调用 mutations 设置 detail
-      commit('USERINFO', api.getO2oUserInfo())
+      api.getO2oUserInfo(function (res) {
+        commit('USERINFO', res.data)
+      })
     }
   }
 }

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