Commit 843fce64ee0c83315d91d4feea9a44d67b4809ff
1 parent
71166190e9
Exists in
master
feat(master): 加入 vuex 的使用
Showing
9 changed files
with
142 additions
and
67 deletions
Show diff stats
.gitignore
1 | .DS_Store | 1 | .DS_Store |
2 | node_modules/ | 2 | node_modules/ |
3 | unpackage/ | 3 | unpackage/ |
4 | dist/ | 4 | dist/ |
5 | .history | ||
5 | 6 | ||
6 | # local env files | 7 | # local env files |
7 | .env.local | 8 | .env.local |
8 | .env.*.local | 9 | .env.*.local |
9 | 10 | ||
10 | # Log files | 11 | # Log files |
11 | npm-debug.log* | 12 | npm-debug.log* |
12 | yarn-debug.log* | 13 | yarn-debug.log* |
13 | yarn-error.log* | 14 | yarn-error.log* |
14 | 15 | ||
15 | # Editor directories and files | 16 | # Editor directories and files |
16 | .project | 17 | .project |
17 | .idea | 18 | .idea |
18 | .vscode | 19 | .vscode |
19 | *.suo | 20 | *.suo |
20 | *.ntvs* | 21 | *.ntvs* |
21 | *.njsproj | 22 | *.njsproj |
22 | *.sln | 23 | *.sln |
23 | *.sw* | 24 | *.sw* |
24 | yarn.lock | 25 | yarn.lock |
25 | 26 |
src/App.vue
1 | <script lang="ts"> | 1 | <script lang="ts"> |
2 | import Vue from 'vue'; | 2 | import Vue from 'vue'; |
3 | export default Vue.extend({ | 3 | export default Vue.extend({ |
4 | mpType: 'app', | 4 | mpType: 'app', |
5 | onLaunch() { | 5 | onLaunch() { |
6 | console.log('App Launch') | 6 | console.log('App Launch') |
7 | }, | 7 | }, |
8 | onShow() { | 8 | onShow() { |
9 | 9 | ||
10 | console.log('App Show') | 10 | console.log('App Show') |
11 | }, | 11 | }, |
12 | onHide() { | 12 | onHide() { |
13 | console.log('App Hide') | 13 | console.log('App Hide') |
14 | } | 14 | } |
15 | }); | 15 | }); |
16 | </script> | 16 | </script> |
17 | 17 | ||
18 | <style> | 18 | <style> |
19 | /*每个页面公共css */ | 19 | /*每个页面公共css */ |
20 | </style> | 20 | </style> |
21 | 21 |
src/main.js
File was created | 1 | import Vue from 'vue' | |
2 | import App from './App.vue' | ||
3 | import store from './store/index' | ||
4 | |||
5 | Vue.config.productionTip = false | ||
6 | Vue.prototype.sendRequest = function(param){ | ||
7 | let _self = this, | ||
8 | url = param.url, | ||
9 | data = param.data, | ||
10 | header = param.header, | ||
11 | token = ''; | ||
12 | //拼接完整请求url | ||
13 | let requestUrl = this.baseUrl + url; | ||
14 | } | ||
15 | |||
16 | |||
17 | new App({store}).$mount() | ||
18 |
src/main.ts
1 | import Vue from 'vue' | File was deleted | |
2 | import App from './App.vue' | ||
3 | |||
4 | |||
5 | Vue.config.productionTip = false | ||
6 | Vue.prototype.sendRequest = function(param:any){ | ||
7 | let _self = this, | ||
8 | url = param.url, | ||
9 | data = param.data, | ||
10 | header = param.header, | ||
11 | token = ''; | ||
12 | //拼接完整请求url | ||
13 | let requestUrl = this.baseUrl + url; | ||
14 | |||
15 | |||
16 | |||
17 | } | ||
18 | new App().$mount() | ||
19 | 1 | import Vue from 'vue' |
src/pages/addArddess/addArddess.vue
1 | <template> | 1 | <template> |
2 | <view class="wrap"> | 2 | <view class="wrap"> |
3 | <view class="content"> | 3 | <view class="content"> |
4 | <view class="item,name" > | 4 | <view class="item,name" > |
5 | <text class="itemText">姓名</text> | 5 | <text class="itemText">姓名</text> |
6 | <input placeholder="收货人姓名(真实姓名)" placeholder-style="color:#B8B8B8"/> | 6 | <input placeholder="收货人姓名(真实姓名)" placeholder-style="color:#B8B8B8"/> |
7 | </view> | 7 | </view> |
8 | <view class="item,phone"> | 8 | <view class="item,phone"> |
9 | <text class="itemText">电话</text> | 9 | <text class="itemText">电话</text> |
10 | <input placeholder="手机号" type="digit" placeholder-style="color:#B8B8B8"/> | 10 | <input placeholder="手机号" type="digit" placeholder-style="color:#B8B8B8"/> |
11 | </view> | 11 | </view> |
12 | <view class="item,area" > | 12 | <view class="item,area" > |
13 | <text class="itemText">地区</text> | 13 | <text class="itemText">地区</text> |
14 | <view class="btn" v-if="pickerText===''" @tap="openAddres">选择省/市/区</view> | 14 | <view class="btn" v-if="pickerText===''" @tap="openAddres">选择省/市/区</view> |
15 | <view class="btn" v-else @tap="openAddres">{{pickerText}}</view> | 15 | <view class="btn" v-else @tap="openAddres">{{pickerText}}</view> |
16 | <simple-address ref="SimpleAddress" :pickerValueDefault="cityPickerValueDefault" @onConfirm="onConfirm" themeColor="#007AFF"></simple-address> | 16 | <simple-address ref="SimpleAddress" :pickerValueDefault="cityPickerValueDefault" @onConfirm="onConfirm" themeColor="#007AFF"></simple-address> |
17 | </view> | 17 | </view> |
18 | <view class="item,address" > | 18 | <view class="item,address" > |
19 | <text class="itemText">详细地址</text> | 19 | <text class="itemText">详细地址</text> |
20 | <input placeholder="街道、小区门牌等详细地址"/> | 20 | <input placeholder="街道、小区门牌等详细地址"/> |
21 | </view> | 21 | </view> |
22 | <view class="item,check" > | 22 | <view class="item,check" > |
23 | <text class="itemText">设为默认地址</text> | 23 | <text class="itemText">设为默认地址</text> |
24 | <switch checked="isDefalutAddress" color="#FF6B4A" style="transform:scale(0.6)" @change="changeDefalutAddress" /> | 24 | <switch checked="isDefalutAddress" color="#FF6B4A" style="transform:scale(0.6)" @change="changeDefalutAddress" /> |
25 | </view> | 25 | </view> |
26 | <input /> | 26 | <input /> |
27 | </view> | 27 | </view> |
28 | <view class="button">保存并使用</view> | 28 | <view class="button">保存并使用</view> |
29 | </view> | 29 | </view> |
30 | </template> | 30 | </template> |
31 | 31 | ||
32 | <script> | 32 | <script> |
33 | import SimpleAddress from '@/components/Simple-address/Simple-address.vue'; | 33 | import SimpleAddress from '@/components/Simple-address/simple-address.vue'; |
34 | export default { | 34 | export default { |
35 | data() { | 35 | data() { |
36 | return { | 36 | return { |
37 | cityPickerValueDefault: [0, 0, 1], | 37 | cityPickerValueDefault: [0, 0, 1], |
38 | pickerText: '', | 38 | pickerText: '', |
39 | isDefalutAddress:true | 39 | isDefalutAddress:true |
40 | 40 | ||
41 | }; | 41 | }; |
42 | }, | 42 | }, |
43 | components: { | 43 | components: { |
44 | SimpleAddress | 44 | SimpleAddress |
45 | }, | 45 | }, |
46 | methods: { | 46 | methods: { |
47 | openAddres() { | 47 | openAddres() { |
48 | this.cityPickerValueDefault = [0,0,1] | 48 | this.cityPickerValueDefault = [0,0,1] |
49 | this.$refs.SimpleAddress.open(); | 49 | this.$refs.SimpleAddress.open(); |
50 | }, | 50 | }, |
51 | onConfirm(e) { | 51 | onConfirm(e) { |
52 | this.pickerText = e.label; | 52 | this.pickerText = e.label; |
53 | }, | 53 | }, |
54 | changeDefalutAddress(e){ | 54 | changeDefalutAddress(e){ |
55 | this.isDefalutAddress = e.target.value | 55 | this.isDefalutAddress = e.target.value |
56 | } | 56 | } |
57 | } | 57 | } |
58 | } | 58 | } |
59 | </script> | 59 | </script> |
60 | 60 | ||
61 | <style lang="scss"> | 61 | <style lang="scss"> |
62 | .wrap{ | 62 | .wrap{ |
63 | height: 100vh; | 63 | height: 100vh; |
64 | background-color:#F2F2F2 ; | 64 | background-color:#F2F2F2 ; |
65 | font-family: PingFangSC-Regular; | 65 | font-family: PingFangSC-Regular; |
66 | letter-spacing: -0.23px; | 66 | letter-spacing: -0.23px; |
67 | padding-top: 19rpx; | 67 | padding-top: 19rpx; |
68 | } | 68 | } |
69 | .content{ | 69 | .content{ |
70 | background-color: #FFFFFF; | 70 | background-color: #FFFFFF; |
71 | border-radius: 8px; | 71 | border-radius: 8px; |
72 | border-radius: 8px; | 72 | border-radius: 8px; |
73 | padding: 40rpx 56rpx; | 73 | padding: 40rpx 56rpx; |
74 | margin-left: 40rpx; | 74 | margin-left: 40rpx; |
75 | width: 670rpx; | 75 | width: 670rpx; |
76 | box-sizing: border-box; | 76 | box-sizing: border-box; |
77 | .item{ | 77 | .item{ |
78 | display: flex; | 78 | display: flex; |
79 | justify-content: flex-start; | 79 | justify-content: flex-start; |
80 | font-size: 14px; | 80 | font-size: 14px; |
81 | align-items: center; | 81 | align-items: center; |
82 | height: 112rpx; | 82 | height: 112rpx; |
83 | border-bottom: 1rpx solid #E9E9E9; | 83 | border-bottom: 1rpx solid #E9E9E9; |
84 | .itemText{ | 84 | .itemText{ |
85 | width: 162rpx; | 85 | width: 162rpx; |
86 | font-family: PingFangSC-Regular; | 86 | font-family: PingFangSC-Regular; |
87 | letter-spacing: -0.26px; | 87 | letter-spacing: -0.26px; |
88 | } | 88 | } |
89 | .btn{ | 89 | .btn{ |
90 | color: #333333 !important; | 90 | color: #333333 !important; |
91 | } | 91 | } |
92 | } | 92 | } |
93 | .check{ | 93 | .check{ |
94 | justify-content: space-between; | 94 | justify-content: space-between; |
95 | } | 95 | } |
96 | } | 96 | } |
97 | .button{ | 97 | .button{ |
98 | position: fixed; | 98 | position: fixed; |
99 | bottom: 0; | 99 | bottom: 0; |
100 | left: 0; | 100 | left: 0; |
101 | height: 112rpx; | 101 | height: 112rpx; |
102 | width: 100%; | 102 | width: 100%; |
103 | background: #FF6B4A; | 103 | background: #FF6B4A; |
104 | display: flex; | 104 | display: flex; |
105 | justify-content: center; | 105 | justify-content: center; |
106 | align-items: center; | 106 | align-items: center; |
107 | font-size: 16px; | 107 | font-size: 16px; |
108 | color: #FFFFFF; | 108 | color: #FFFFFF; |
109 | letter-spacing: -0.3px; | 109 | letter-spacing: -0.3px; |
110 | } | 110 | } |
111 | </style> | 111 | </style> |
112 | 112 |
src/pages/index/index.vue
1 | <template> | 1 | <template> |
2 | <view class="content"> | 2 | <view class="content"> |
3 | <view class="header"> | 3 | <view class="header"> |
4 | <!-- 搜索--> | 4 | <!-- 搜索--> |
5 | <view class="searchBar"> | 5 | <view class="searchBar"> |
6 | <icon class="searchIcon" type="search" size="14"></icon> | 6 | <icon class="searchIcon" type="search" size="14"></icon> |
7 | <input class="searchIpt" placeholder="老花镜" confirm-type="search" /> | 7 | <input class="searchIpt" placeholder="老花镜" confirm-type="search" /> |
8 | </view> | 8 | </view> |
9 | 9 | ||
10 | <!-- 筛选栏--> | 10 | <!-- 筛选栏--> |
11 | <view class="screenBar"> | 11 | <view class="screenBar"> |
12 | <view v-for="item in screenItems" :key="item.current" @click="onClickItem(item.current)"> | 12 | <view v-for="item in screenItems" :key="item.current" @click="onClickItem(item.current)"> |
13 | <view | 13 | <view |
14 | class="screenItem" | 14 | class="screenItem" |
15 | v-bind:class="{ active: current === item.current }" | 15 | v-bind:class="{ active: current === item.current }" |
16 | v-if="item.current === 2" | 16 | v-if="item.current === 2" |
17 | @click="dropDown" | 17 | @click="dropDown" |
18 | > | 18 | > |
19 | {{ item.text }} | 19 | {{ item.text }} |
20 | <icon type="info" size="14"></icon> | 20 | <icon type="info" size="14"></icon> |
21 | </view> | 21 | </view> |
22 | <view | 22 | <view |
23 | class="screenItem" | 23 | class="screenItem" |
24 | v-bind:class="{ active: current === item.current }" | 24 | v-bind:class="{ active: current === item.current }" |
25 | v-if="item.current === 4" | 25 | v-if="item.current === 4" |
26 | @click="showDrawer('showRight')" | 26 | @click="showDrawer('showRight')" |
27 | > | 27 | > |
28 | {{ item.text }} | 28 | {{ item.text }} |
29 | <icon type="info" size="14"></icon> | 29 | <icon type="info" size="14"></icon> |
30 | </view> | 30 | </view> |
31 | <view v-if="item.current !== 2&&item.current!==4"> | 31 | <view v-if="item.current !== 2&&item.current!==4"> |
32 | <view | 32 | <view |
33 | class="screenItem" | 33 | class="screenItem" |
34 | v-bind:class="{ active: current === item.current }" | 34 | v-bind:class="{ active: current === item.current }" |
35 | >{{ item.text }}</view> | 35 | >{{ item.text }}</view> |
36 | </view> | 36 | </view> |
37 | </view> | 37 | </view> |
38 | </view> | 38 | </view> |
39 | </view> | 39 | </view> |
40 | <Uni-drawer | 40 | <Uni-drawer |
41 | ref="showRight" | 41 | ref="showRight" |
42 | mask="true" | 42 | mask="true" |
43 | maskClick="true" | 43 | maskClick="true" |
44 | mode="right" | 44 | mode="right" |
45 | :width="320" | 45 | :width="320" |
46 | @change="change($event,'showRight')" | 46 | @change="change($event,'showRight')" |
47 | > | 47 | > |
48 | <view class="close"> | 48 | <view class="close"> |
49 | <view @click="closeDrawer('showRight')"> | 49 | <view @click="closeDrawer('showRight')"> |
50 | <text class="word-btn-white">关闭</text> | 50 | <text class="word-btn-white">关闭</text> |
51 | </view> | 51 | </view> |
52 | </view> | 52 | </view> |
53 | </Uni-drawer> | 53 | </Uni-drawer> |
54 | 54 | ||
55 | <!-- 筛选菜单--> | 55 | <!-- 筛选菜单--> |
56 | <view class="content-wrap"> | 56 | <view class="content-wrap"> |
57 | <view> | 57 | <view> |
58 | <HMfilterDropdown | 58 | <HMfilterDropdown |
59 | :filterData="filterData" | 59 | :filterData="filterData" |
60 | :defaultSelected="filterDropdownValue" | 60 | :defaultSelected="filterDropdownValue" |
61 | :updateMenuName="true" | 61 | :updateMenuName="true" |
62 | @confirm="confirm" | 62 | @confirm="confirm" |
63 | data-format="Object" | 63 | data-format="Object" |
64 | ></HMfilterDropdown> | 64 | ></HMfilterDropdown> |
65 | <!-- 商品列表 --> | 65 | <!-- 商品列表 --> |
66 | <view class="goods-list"> | 66 | <view class="goods-list"> |
67 | <view class="product-list"> | 67 | <view class="product-list"> |
68 | <view class="product" v-for="(goods) in goodsList" :key="goods.id"> | 68 | <view class="product" v-for="(goods) in goodsList" :key="goods.id"> |
69 | <Card :goods="goods"></Card> | 69 | <Card :goods="goods"></Card> |
70 | </view> | 70 | </view> |
71 | </view> | 71 | </view> |
72 | <view class="loading-text">{{loadingText}}</view> | 72 | <view class="loading-text">{{loadingText}}</view> |
73 | </view> | 73 | </view> |
74 | </view> | 74 | </view> |
75 | </view> | 75 | </view> |
76 | </view> | 76 | </view> |
77 | </template> | 77 | </template> |
78 | 78 | ||
79 | <script> | 79 | <script> |
80 | import UniDrawer from "@/components/Uni-drawer/Uni-drawer.vue"; | 80 | import UniDrawer from "../../components/uni-drawer/uni-drawer.vue"; |
81 | import Card from "../../components/Card/Card.vue"; | 81 | import Card from "../../components/Card/Card.vue"; |
82 | import HMfilterDropdown from "../../components/HM-filterDropdown/HM-filterDropdown.vue"; | 82 | import HMfilterDropdown from "../../components/HM-filterDropdown/HM-filterDropdown.vue"; |
83 | import data from "@/common/data.js"; //筛选菜单数据 | 83 | import data from "@/common/data.js"; //筛选菜单数据 |
84 | import store from '@/store'; | ||
85 | |||
84 | export default { | 86 | export default { |
85 | components: { | 87 | components: { |
86 | UniDrawer: UniDrawer, | 88 | UniDrawer: UniDrawer, |
87 | HMfilterDropdown: HMfilterDropdown, | 89 | HMfilterDropdown: HMfilterDropdown, |
88 | Card: Card | 90 | Card: Card |
89 | }, | 91 | }, |
90 | data() { | 92 | data() { |
91 | return { | 93 | return { |
92 | screenItems: [ | 94 | screenItems: [ |
93 | { current: 0, text: "全部", hasIcon: false }, | 95 | { current: 0, text: "全部", hasIcon: false }, |
94 | { current: 1, text: "销量", hasIcon: false }, | 96 | { current: 1, text: "销量", hasIcon: false }, |
95 | { current: 2, text: "价格", hasIcon: true }, | 97 | { current: 2, text: "价格", hasIcon: true }, |
96 | { current: 3, text: "折扣", hasIcon: false }, | 98 | { current: 3, text: "折扣", hasIcon: false }, |
97 | { current: 4, text: "筛选", hasIcon: true } | 99 | { current: 4, text: "筛选", hasIcon: true } |
98 | ], | 100 | ], |
99 | current: 0, | 101 | current: 0, |
100 | showRight: false, | 102 | showRight: false, |
101 | indexArr: "", | 103 | indexArr: "", |
102 | valueArr: "", | 104 | valueArr: "", |
103 | // //商品数据 | 105 | // //商品数据 |
104 | goodsList: [ | 106 | // goodsList: [ |
105 | { | 107 | // { |
106 | // goods_id: 0, | 108 | // // goods_id: 0, |
107 | // img: "/static/img/goods/p1.jpg", | 109 | // // img: "/static/img/goods/p1.jpg", |
108 | // name: "商品名称", | 110 | // // name: "商品名称", |
109 | // originCost: "¥198", | 111 | // // originCost: "¥198", |
110 | // price: "¥168", | 112 | // // price: "¥168", |
111 | // slogan: "1235人浏览" | 113 | // // slogan: "1235人浏览" |
112 | } | 114 | // } |
113 | ], | 115 | // ], |
114 | loadingText: "正在加载...", | 116 | loadingText: "正在加载...", |
115 | filterDropdownValue: [], | 117 | filterDropdownValue: [], |
116 | filterData: [] | 118 | filterData: [] |
117 | }; | 119 | }; |
118 | }, | 120 | }, |
121 | computed: { | ||
122 | goodsList() { | ||
123 | // 也可以从 getters 获取 | ||
124 | console.log(this.$store.getters.list); | ||
125 | return this.$store.state.test.list; | ||
126 | } | ||
127 | }, | ||
119 | filters: { | 128 | filters: { |
120 | outData(value) { | 129 | outData(value) { |
121 | return JSON.stringify(value); | 130 | return JSON.stringify(value); |
122 | } | 131 | } |
123 | }, | 132 | }, |
124 | onLoad: function() { | 133 | onLoad: function() { |
125 | uni.request({ | 134 | store.dispatch('test/fetch'); |
126 | url: "https://api.glass.xiuyetang.com/app/prod/list", | 135 | // uni.request({ |
127 | method: "post", | 136 | // url: "https://api.glass.xiuyetang.com/app/prod/list", |
128 | data: { | 137 | // method: "post", |
129 | // text: 'uni.request' | 138 | // data: { |
130 | }, | 139 | // // text: 'uni.request' |
131 | header: { | 140 | // }, |
132 | // 'custom-header': 'hello', //自定义请求头信息 | 141 | // header: { |
133 | "Content-Type": "application/x-www-form-urlencoded" | 142 | // // 'custom-header': 'hello', //自定义请求头信息 |
134 | // 'Content-Type':'multipart/form-data' | 143 | // "Content-Type": "application/x-www-form-urlencoded" |
135 | // 'Content-Type':'ext/plain' | 144 | // // 'Content-Type':'multipart/form-data' |
136 | }, | 145 | // // 'Content-Type':'ext/plain' |
137 | timeout: 3000, | 146 | // }, |
138 | // dataType:'json' | 147 | // timeout: 3000, |
139 | // responseType:'text', | 148 | // // dataType:'json' |
140 | // sslVerify: true,//验证 ssl 证书 | 149 | // // responseType:'text', |
141 | withCredentials: false, //跨域请求时是否携带凭证(cookies) | 150 | // // sslVerify: true,//验证 ssl 证书 |
142 | success: res => { | 151 | // withCredentials: false, //跨域请求时是否携带凭证(cookies) |
143 | console.error("success status === > ", res); | 152 | // success: res => { |
144 | this.goodsList = res.data.data; | 153 | // console.error("success status === > ", res); |
145 | // console.log('res.data', res.data); | 154 | // this.goodsList = res.data.data; |
146 | // this.text = 'request success'; | 155 | // // console.log('res.data', res.data); |
147 | }, | 156 | // // this.text = 'request success'; |
148 | fail: res => { | 157 | // }, |
149 | console.log("fail status === > ", res); | 158 | // fail: res => { |
150 | }, | 159 | // console.log("fail status === > ", res); |
151 | complete: res => { | 160 | // }, |
152 | console.log("complete status === > ", res); | 161 | // complete: res => { |
153 | } | 162 | // console.log("complete status === > ", res); |
154 | }); | 163 | // } |
164 | // }); | ||
155 | //定时器模拟ajax异步请求数据 | 165 | //定时器模拟ajax异步请求数据 |
156 | // setTimeout(()=>{ | 166 | // setTimeout(()=>{ |
157 | // //传入defaultSelected的结构不能错,错了就报错运行异常。 不选中的项目传入null | 167 | // //传入defaultSelected的结构不能错,错了就报错运行异常。 不选中的项目传入null |
158 | // this.filterDropdownValue = [ | 168 | // this.filterDropdownValue = [ |
159 | // [1,1,0], //第0个菜单选中 一级菜单的第1项,二级菜单的第1项,三级菜单的第3项 | 169 | // [1,1,0], //第0个菜单选中 一级菜单的第1项,二级菜单的第1项,三级菜单的第3项 |
160 | // [null,null], //第1个菜单选中 都不选中 | 170 | // [null,null], //第1个菜单选中 都不选中 |
161 | // [1], //第2个菜单选中 一级菜单的第1项 | 171 | // [1], //第2个菜单选中 一级菜单的第1项 |
162 | // [[0],[1,2,7],[1,0]], //筛选菜单选中 第一个筛选的第0项,第二个筛选的第1,2,7项,第三个筛选的第1,0项 | 172 | // [[0],[1,2,7],[1,0]], //筛选菜单选中 第一个筛选的第0项,第二个筛选的第1,2,7项,第三个筛选的第1,0项 |
163 | // [[0],[1],[1]], //单选菜单选中 第一个筛选的第0项,第二个筛选的第1项,第三个筛选的第1项 | 173 | // [[0],[1],[1]], //单选菜单选中 第一个筛选的第0项,第二个筛选的第1项,第三个筛选的第1项 |
164 | // ]; | 174 | // ]; |
165 | // this.filterData = data; | 175 | // this.filterData = data; |
166 | // },100); | 176 | // },100); |
167 | // 模拟ajax请求子菜单数据。 | 177 | // 模拟ajax请求子菜单数据。 |
168 | // setTimeout(()=>{ | 178 | // setTimeout(()=>{ |
169 | // console.log('发起请求','ddddddd'); | 179 | // console.log('发起请求','ddddddd'); |
170 | // // this.filterData[1].submenu[0].submenu = [{"name": "附近","value": "附近"},{"name": "1km","value": "1km"},{"name": "2km","value": "2km"},{"name": "3km","value": "3km"},{"name": "4km","value": "4km"},{"name": "5km","value": "5km"}]; | 180 | // // this.filterData[1].submenu[0].submenu = [{"name": "附近","value": "附近"},{"name": "1km","value": "1km"},{"name": "2km","value": "2km"},{"name": "3km","value": "3km"},{"name": "4km","value": "4km"},{"name": "5km","value": "5km"}]; |
171 | // },3000); | 181 | // },3000); |
172 | }, | 182 | }, |
173 | methods: { | 183 | methods: { |
174 | showDrawer(e) { | 184 | showDrawer(e) { |
175 | this.$refs[e].open(); | 185 | this.$refs[e].open(); |
176 | }, | 186 | }, |
177 | closeDrawer(e) { | 187 | closeDrawer(e) { |
178 | this.$refs[e].close(); | 188 | this.$refs[e].close(); |
179 | }, | 189 | }, |
180 | change(e, type) { | 190 | change(e, type) { |
181 | this[type] = e; | 191 | this[type] = e; |
182 | }, | 192 | }, |
183 | onClickItem(e) { | 193 | onClickItem(e) { |
184 | if (this.current !== e) { | 194 | if (this.current !== e) { |
185 | this.current = e; | 195 | this.current = e; |
186 | } | 196 | } |
187 | }, | 197 | }, |
188 | dropDown() { | 198 | dropDown() { |
189 | console.log("下拉"); | 199 | console.log("下拉"); |
190 | }, | 200 | }, |
191 | //接收菜单结果 | 201 | //接收菜单结果 |
192 | confirm(e) { | 202 | confirm(e) { |
193 | this.indexArr = e.index; | 203 | this.indexArr = e.index; |
194 | this.valueArr = e.value; | 204 | this.valueArr = e.value; |
195 | return; | 205 | return; |
196 | console.log("修改菜单"); | 206 | console.log("修改菜单"); |
197 | this.filterData[4].submenu[1] = { | 207 | this.filterData[4].submenu[1] = { |
198 | name: "项目2", | 208 | name: "项目2", |
199 | submenu: [] | 209 | submenu: [] |
200 | }; | 210 | }; |
201 | } | 211 | } |
202 | }, | 212 | }, |
203 | onNavigationBarButtonTap(e) { | 213 | onNavigationBarButtonTap(e) { |
204 | this.showRight = !this.showRight; | 214 | this.showRight = !this.showRight; |
205 | }, | 215 | }, |
206 | //上拉加载, | 216 | //上拉加载, |
207 | onReachBottom() { | 217 | onReachBottom() { |
208 | console.log("到底加载"); | 218 | console.log("到底加载"); |
209 | let len = this.goodsList.length; | 219 | let len = this.goodsList.length; |
210 | if (len >= 30) { | 220 | if (len >= 30) { |
211 | this.loadingText = "~~到底了~~"; | 221 | this.loadingText = "~~到底了~~"; |
212 | return false; | 222 | return false; |
213 | } else { | 223 | } else { |
214 | this.loadingText = "正在加载..."; | 224 | this.loadingText = "正在加载..."; |
215 | } | 225 | } |
216 | let end_goods_id = this.goodsList[len - 1].goods_id; | 226 | let end_goods_id = this.goodsList[len - 1].goods_id; |
217 | for (let i = 1; i <= 10; i++) { | 227 | for (let i = 1; i <= 10; i++) { |
218 | let goods_id = end_goods_id + i; | 228 | let goods_id = end_goods_id + i; |
219 | let p = { | 229 | let p = { |
220 | goods_id: goods_id, | 230 | goods_id: goods_id, |
221 | img: | 231 | img: |
222 | "/static/img/goods/p" + | 232 | "/static/img/goods/p" + |
223 | (goods_id % 10 == 0 ? 10 : goods_id % 10) + | 233 | (goods_id % 10 == 0 ? 10 : goods_id % 10) + |
224 | ".jpg", | 234 | ".jpg", |
225 | name: "商品名称", | 235 | name: "商品名称", |
226 | originCost: "¥198", | 236 | originCost: "¥198", |
227 | price: "¥168", | 237 | price: "¥168", |
228 | slogan: "1235人付款" | 238 | slogan: "1235人付款" |
229 | }; | 239 | }; |
230 | this.goodsList.push(p); | 240 | this.goodsList.push(p); |
231 | } | 241 | } |
232 | } | 242 | } |
233 | }; | 243 | }; |
234 | </script> | 244 | </script> |
235 | 245 | ||
236 | <style lang="scss"> | 246 | <style lang="scss"> |
237 | .content { | 247 | .content { |
238 | display: flex; | 248 | display: flex; |
239 | flex-direction: column; | 249 | flex-direction: column; |
240 | align-items: center; | 250 | align-items: center; |
241 | justify-content: center; | 251 | justify-content: center; |
242 | background-color: #f7f6f6; | 252 | background-color: #f7f6f6; |
243 | } | 253 | } |
244 | .header { | 254 | .header { |
245 | display: flex; | 255 | display: flex; |
246 | flex-direction: column; | 256 | flex-direction: column; |
247 | align-items: center; | 257 | align-items: center; |
248 | justify-content: center; | 258 | justify-content: center; |
249 | background-color: #f7f6f6; | 259 | background-color: #f7f6f6; |
250 | height: 178rpx; | 260 | height: 178rpx; |
251 | width: 100%; | 261 | width: 100%; |
252 | z-index: 999; | 262 | z-index: 999; |
253 | position: fixed; | 263 | position: fixed; |
254 | top: 0; | 264 | top: 0; |
255 | left: 0; | 265 | left: 0; |
256 | } | 266 | } |
257 | .searchBar { | 267 | .searchBar { |
258 | width: 670rpx; | 268 | width: 670rpx; |
259 | display: flex; | 269 | display: flex; |
260 | justify-content: center; | 270 | justify-content: center; |
261 | align-items: center; | 271 | align-items: center; |
262 | box-sizing: border-box; | 272 | box-sizing: border-box; |
263 | padding: 0rpx 16rpx; | 273 | padding: 0rpx 16rpx; |
264 | border: 1px solid #ff6b4a; | 274 | border: 1px solid #ff6b4a; |
265 | border-radius: 8rpx; | 275 | border-radius: 8rpx; |
266 | background-color: #ffffff; | 276 | background-color: #ffffff; |
267 | } | 277 | } |
268 | 278 | ||
269 | .searchIpt { | 279 | .searchIpt { |
270 | height: 68rpx; | 280 | height: 68rpx; |
271 | width: 670rpx; | 281 | width: 670rpx; |
272 | padding: 16rpx; | 282 | padding: 16rpx; |
273 | font-size: 28rpx; | 283 | font-size: 28rpx; |
274 | box-sizing: border-box; | 284 | box-sizing: border-box; |
275 | } | 285 | } |
276 | .screenBar { | 286 | .screenBar { |
277 | width: 670rpx; | 287 | width: 670rpx; |
278 | height: 110rpx; | 288 | height: 110rpx; |
279 | display: flex; | 289 | display: flex; |
280 | flex-direction: row; | 290 | flex-direction: row; |
281 | justify-content: space-between; | 291 | justify-content: space-between; |
282 | align-items: center; | 292 | align-items: center; |
283 | color: #333333; | 293 | color: #333333; |
284 | font-size: 32rpx; | 294 | font-size: 32rpx; |
285 | } | 295 | } |
286 | .active { | 296 | .active { |
287 | color: #ff6b4a; | 297 | color: #ff6b4a; |
288 | } | 298 | } |
289 | .screenItem { | 299 | .screenItem { |
290 | display: flex; | 300 | display: flex; |
291 | justify-content: center; | 301 | justify-content: center; |
292 | align-items: center; | 302 | align-items: center; |
293 | } | 303 | } |
294 | .content-wrap { | 304 | .content-wrap { |
295 | width: 100%; | 305 | width: 100%; |
296 | background-color: #ffffff; | 306 | background-color: #ffffff; |
297 | } | 307 | } |
298 | 308 | ||
299 | .HMfilterDropdown { | 309 | .HMfilterDropdown { |
300 | top: 178rpx !important; | 310 | top: 178rpx !important; |
301 | } | 311 | } |
302 | 312 | ||
303 | .goods-list { | 313 | .goods-list { |
304 | padding-top: 286rpx; | 314 | padding-top: 286rpx; |
305 | .loading-text { | 315 | .loading-text { |
306 | width: 100%; | 316 | width: 100%; |
307 | display: flex; | 317 | display: flex; |
308 | justify-content: center; | 318 | justify-content: center; |
309 | align-items: center; | 319 | align-items: center; |
310 | height: 30px; | 320 | height: 30px; |
311 | color: #979797; | 321 | color: #979797; |
312 | font-size: 12px; | 322 | font-size: 12px; |
313 | } | 323 | } |
314 | .product-list { | 324 | .product-list { |
315 | width: 92%; | 325 | width: 92%; |
316 | padding: 0 4% 3vw 4%; | 326 | padding: 0 4% 3vw 4%; |
317 | display: flex; | 327 | display: flex; |
318 | justify-content: space-between; | 328 | justify-content: space-between; |
319 | flex-wrap: wrap; | 329 | flex-wrap: wrap; |
320 | .product { | 330 | .product { |
321 | width: 48%; | 331 | width: 48%; |
322 | margin: 0 0 20rpx 0; | 332 | margin: 0 0 20rpx 0; |
323 | background: #ffffff; | 333 | background: #ffffff; |
324 | border: 1px solid #f2f2f2; | 334 | border: 1px solid #f2f2f2; |
325 | } | 335 | } |
326 | } | 336 | } |
327 | } | 337 | } |
328 | </style> | 338 | </style> |
329 | 339 |
src/pages/myOrder/myOrder.vue
1 | <template> | 1 | <template> |
2 | <view class="content"> | 2 | <view class="content"> |
3 | <view class="header"> | 3 | <view class="header"> |
4 | <!-- 搜索--> | 4 | <!-- 搜索--> |
5 | <view class="searchBar"> | 5 | <view class="searchBar"> |
6 | <icon class="searchIcon" type="search" size="14"></icon> | 6 | <icon class="searchIcon" type="search" size="14"></icon> |
7 | <input class="searchIpt" placeholder="搜索订单关键字..." confirm-type="search"/> | 7 | <input class="searchIpt" placeholder="搜索订单关键字..." confirm-type="search"/> |
8 | </view> | 8 | </view> |
9 | <view class="screenBar"> | 9 | <view class="screenBar"> |
10 | <view v-for="item in screenItems" :key="item.current" @click="onClickItem(item.current)" > | 10 | <view v-for="item in screenItems" :key="item.current" @click="onClickItem(item.current)" > |
11 | <view class="screenItem" v-bind:class="{ active: current === item.current }">{{ item.text }}</view> | 11 | <view class="screenItem" v-bind:class="{ active: current === item.current }">{{ item.text }}</view> |
12 | </view> | 12 | </view> |
13 | </view> | 13 | </view> |
14 | </view> | 14 | </view> |
15 | <view class="orderList" > | 15 | <view class="orderList" > |
16 | <view v-for="(order) in orderList" :key="order.orderId"> | 16 | <view v-for="(order) in orderList" :key="order.orderId"> |
17 | <OrderCard :order = "order" :current="current"></OrderCard> | 17 | <OrderCard :order = "order" :current="current"></OrderCard> |
18 | </view> | 18 | </view> |
19 | </view> | 19 | </view> |
20 | <view class="footer">已显示全部</view> | 20 | <view class="footer">已显示全部</view> |
21 | </view> | 21 | </view> |
22 | </template> | 22 | </template> |
23 | <script> | 23 | <script> |
24 | import OrderCard from './OrderCard.vue' | 24 | import OrderCard from './orderCard.vue' |
25 | export default { | 25 | export default { |
26 | components:{ | 26 | components:{ |
27 | 'OrderCard':OrderCard | 27 | 'OrderCard':OrderCard |
28 | }, | 28 | }, |
29 | data() { | 29 | data() { |
30 | return { | 30 | return { |
31 | screenItems: [ | 31 | screenItems: [ |
32 | {current:0,text:'全部'}, | 32 | {current:0,text:'全部'}, |
33 | {current:1,text:'待付款'}, | 33 | {current:1,text:'待付款'}, |
34 | {current:2,text:'待发货'}, | 34 | {current:2,text:'待发货'}, |
35 | {current:3,text:'待收货'}, | 35 | {current:3,text:'待收货'}, |
36 | {current:4,text:'退款售后'}, | 36 | {current:4,text:'退款售后'}, |
37 | ], | 37 | ], |
38 | current: 0, | 38 | current: 0, |
39 | //订单数据 | 39 | //订单数据 |
40 | orderList:[ | 40 | orderList:[ |
41 | { orderId: 0, img: '/static/img/goods/p1.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:1 ,buyNum:1}, | 41 | { orderId: 0, img: '/static/img/goods/p1.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:1 ,buyNum:1}, |
42 | { orderId: 2, img: '/static/img/goods/p3.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:1 ,buyNum:1}, | 42 | { orderId: 2, img: '/static/img/goods/p3.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:1 ,buyNum:1}, |
43 | { orderId: 3, img: '/static/img/goods/p4.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:2 ,buyNum:1}, | 43 | { orderId: 3, img: '/static/img/goods/p4.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:2 ,buyNum:1}, |
44 | { orderId: 4, img: '/static/img/goods/p5.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:3 ,buyNum:1}, | 44 | { orderId: 4, img: '/static/img/goods/p5.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:3 ,buyNum:1}, |
45 | { orderId: 5, img: '/static/img/goods/p6.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:3 ,buyNum:1}, | 45 | { orderId: 5, img: '/static/img/goods/p6.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:3 ,buyNum:1}, |
46 | { orderId: 6, img: '/static/img/goods/p7.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:4 ,buyNum:1}, | 46 | { orderId: 6, img: '/static/img/goods/p7.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:4 ,buyNum:1}, |
47 | { orderId: 7, img: '/static/img/goods/p8.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:4 ,buyNum:1}, | 47 | { orderId: 7, img: '/static/img/goods/p8.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:4 ,buyNum:1}, |
48 | { orderId: 8, img: '/static/img/goods/p9.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:5 ,buyNum:1}, | 48 | { orderId: 8, img: '/static/img/goods/p9.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:5 ,buyNum:1}, |
49 | { orderId: 9, img: '/static/img/goods/p10.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:5 ,buyNum:1} | 49 | { orderId: 9, img: '/static/img/goods/p10.jpg', name: '商品名称',originCost:'¥198',price: '¥168', orderType:5 ,buyNum:1} |
50 | ], | 50 | ], |
51 | 51 | ||
52 | }; | 52 | }; |
53 | }, | 53 | }, |
54 | methods:{ | 54 | methods:{ |
55 | onClickItem(e) { | 55 | onClickItem(e) { |
56 | if (this.current !== e) { | 56 | if (this.current !== e) { |
57 | this.current = e; | 57 | this.current = e; |
58 | } | 58 | } |
59 | } | 59 | } |
60 | } | 60 | } |
61 | } | 61 | } |
62 | </script> | 62 | </script> |
63 | 63 | ||
64 | <style lang="scss"> | 64 | <style lang="scss"> |
65 | .content { | 65 | .content { |
66 | display: flex; | 66 | display: flex; |
67 | flex-direction: column; | 67 | flex-direction: column; |
68 | align-items: center; | 68 | align-items: center; |
69 | background-color: #F7F6F6; | 69 | background-color: #F7F6F6; |
70 | min-height: 100vh; | 70 | min-height: 100vh; |
71 | .header{ | 71 | .header{ |
72 | background-color: #ffffff; | 72 | background-color: #ffffff; |
73 | width: 100%; | 73 | width: 100%; |
74 | height: 232rpx; | 74 | height: 232rpx; |
75 | padding: 40rpx 40rpx 36rpx 40rpx; | 75 | padding: 40rpx 40rpx 36rpx 40rpx; |
76 | box-sizing: border-box; | 76 | box-sizing: border-box; |
77 | position: fixed; | 77 | position: fixed; |
78 | top: 0; | 78 | top: 0; |
79 | left: 0; | 79 | left: 0; |
80 | .searchBar { | 80 | .searchBar { |
81 | width: 670rpx; | 81 | width: 670rpx; |
82 | display: flex; | 82 | display: flex; |
83 | justify-content: center; | 83 | justify-content: center; |
84 | align-items: center; | 84 | align-items: center; |
85 | box-sizing: border-box; | 85 | box-sizing: border-box; |
86 | padding: 0rpx 16rpx; | 86 | padding: 0rpx 16rpx; |
87 | border: 1px solid #FF6B4A; | 87 | border: 1px solid #FF6B4A; |
88 | border-radius: 8rpx; | 88 | border-radius: 8rpx; |
89 | background-color: #ffffff; | 89 | background-color: #ffffff; |
90 | } | 90 | } |
91 | 91 | ||
92 | .screenBar{ | 92 | .screenBar{ |
93 | width: 670rpx; | 93 | width: 670rpx; |
94 | height: 110rpx; | 94 | height: 110rpx; |
95 | display: flex; | 95 | display: flex; |
96 | flex-direction: row; | 96 | flex-direction: row; |
97 | justify-content: space-between; | 97 | justify-content: space-between; |
98 | align-items: center; | 98 | align-items: center; |
99 | color: #333333; | 99 | color: #333333; |
100 | font-size: 32rpx; | 100 | font-size: 32rpx; |
101 | } | 101 | } |
102 | .screenItem{ | 102 | .screenItem{ |
103 | height: 50rpx; | 103 | height: 50rpx; |
104 | font-size: 32rpx; | 104 | font-size: 32rpx; |
105 | color: #333333; | 105 | color: #333333; |
106 | display: flex; | 106 | display: flex; |
107 | justify-content: center; | 107 | justify-content: center; |
108 | align-items: center; | 108 | align-items: center; |
109 | transition:all 0.2s; | 109 | transition:all 0.2s; |
110 | } | 110 | } |
111 | .active{ | 111 | .active{ |
112 | // font-size: 34rpx; | 112 | // font-size: 34rpx; |
113 | color: #EC5D3B; | 113 | color: #EC5D3B; |
114 | } | 114 | } |
115 | .searchIpt { | 115 | .searchIpt { |
116 | height: 68rpx; | 116 | height: 68rpx; |
117 | width: 670rpx; | 117 | width: 670rpx; |
118 | padding: 16rpx; | 118 | padding: 16rpx; |
119 | font-size: 28rpx; | 119 | font-size: 28rpx; |
120 | box-sizing: border-box; | 120 | box-sizing: border-box; |
121 | } | 121 | } |
122 | } | 122 | } |
123 | .orderList{ | 123 | .orderList{ |
124 | margin-top: 232rpx; | 124 | margin-top: 232rpx; |
125 | } | 125 | } |
126 | .footer{ | 126 | .footer{ |
127 | font-size: 14px; | 127 | font-size: 14px; |
128 | color: #B8B8B8; | 128 | color: #B8B8B8; |
129 | margin: 40rpx 0; | 129 | margin: 40rpx 0; |
130 | } | 130 | } |
131 | } | 131 | } |
132 | </style> | 132 | </style> |
133 | 133 |
src/store/index.js
File was created | 1 | import Vue from 'vue' | |
2 | import Vuex from 'vuex' | ||
3 | |||
4 | Vue.use(Vuex) | ||
5 | |||
6 | const modulesFiles = require.context('./modules', true, /\.js$/) | ||
7 | |||
8 | const modules = modulesFiles.keys().reduce((modules, modulePath) => { | ||
9 | const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1') | ||
10 | const value = modulesFiles(modulePath) | ||
11 | |||
12 | modules[moduleName] = value.default | ||
13 | |||
14 | return modules | ||
15 | }, {}) | ||
16 | |||
17 | const store = new Vuex.Store({ | ||
18 | modules, | ||
19 | getters: { | ||
20 | list: state => state.test.list | ||
21 | } | ||
22 | }) | ||
23 | |||
24 | export default store; |
src/store/modules/test.js
File was created | 1 | const state = { | |
2 | list: [], | ||
3 | }; | ||
4 | |||
5 | const mutations = { | ||
6 | INIT: (state, list) => { | ||
7 | state.list = list; | ||
8 | }, | ||
9 | }; | ||
10 | |||
11 | const actions = { | ||
12 | fetch({ commit }, param) { | ||
13 | uni | ||
14 | .request({ | ||
15 | url: "https://api.glass.xiuyetang.com/app/prod/list", | ||
16 | method: "post", | ||
17 | data: {}, | ||
18 | header: { | ||
19 | "Content-Type": "application/x-www-form-urlencoded", | ||
20 | }, | ||
21 | timeout: 3000, | ||
22 | withCredentials: false, | ||
23 | success: (res) => { | ||
24 | commit('INIT', res.data.data) | ||
25 | }, | ||
26 | fail: (res) => { | ||
27 | console.log("fail status === > ", res); | ||
28 | }, | ||
29 | complete: (res) => { | ||
30 | console.log("complete status === > ", res); | ||
31 | }, | ||
32 | }); | ||
33 | }, | ||
34 | }; | ||
35 | |||
36 | export default { | ||
37 | namespaced: true, | ||
38 | state, | ||
39 | mutations, | ||
40 | actions, | ||
41 | }; | ||
42 |