order.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <scroll-view scroll-y="true" class="scroll-view">
  6. <view class="list-scroll-view">
  7. <view class="one_1">
  8. <text class="localicon iconfont icon-dingweixiao"></text>
  9. <view class="other" v-if="info._id">
  10. <view class="name">
  11. <text>{{info.name}},</text>{{info.phone}}
  12. </view>
  13. <view class="other_1">
  14. <text>{{info.province}}</text><text>{{info.city}}</text>
  15. <text>{{info.area}}</text><text>{{info.address}}</text>
  16. </view>
  17. </view>
  18. <view class="address" v-else><text>请选择一个收货地址</text></view>
  19. <text @click="toChoose" class="iconfont icon-jiantouyou"></text>
  20. </view>
  21. <view class="one_2">
  22. <view class="list" v-for="(item,index) in orderList" :key="index">
  23. <view class="list_1">
  24. <view class="l">
  25. <text class="iconfont icon-shangdian"></text>
  26. <text>{{item.shop}}</text>
  27. </view>
  28. </view>
  29. <view class="list_2">
  30. <view class="l">
  31. <image class="image" :src="item.url&&item.url.length>0?item.url[0].url:''"
  32. mode=""></image>
  33. </view>
  34. <view class="c">
  35. <view class="name">
  36. {{item.name}}
  37. </view>
  38. </view>
  39. <view class="r">
  40. <view class="price">
  41. ¥{{item.price}}
  42. </view>
  43. <view class="num">
  44. ×{{item.buy_num}}
  45. </view>
  46. </view>
  47. </view>
  48. <view class="list_3">
  49. <view class="other">
  50. <view class="other_1">配送方式</view>
  51. <view class="other_2"><text class="iconfont icon-duihao"></text>快递配送</view>
  52. </view>
  53. <view class="other">
  54. <view class="other_1">运费</view>
  55. <view class="other_2" v-if="!shop.freight==0">¥{{shop.freight}}</view>
  56. <view class="other_2" v-else>包邮</view>
  57. </view>
  58. <view class="other">
  59. <view class="other_1">订单备注</view>
  60. <view class="other_3">
  61. <input type="text" v-model="shop.remarks" placeholder="选填,可填写您与卖家达成一致的要求" />
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </scroll-view>
  69. </view>
  70. <view class="two">
  71. <view class="two_1">
  72. <view>实付金额:</view>
  73. <view>¥{{shop.money}}</view>
  74. </view>
  75. <view class="two_2">
  76. <text @click="toSubmit">提交订单</text>
  77. </view>
  78. </view>
  79. </view>
  80. <uni-popup ref="popup" background-color="#fff" type="right">
  81. <view class="content" v-for="(item,index) in addressList" :key="index">
  82. <view class="one">
  83. <view class="one_1">
  84. <view class="name">
  85. <text>{{item.name}},</text>{{item.phone}}
  86. </view>
  87. <view class="address">
  88. <text>{{item.province}}</text><text>{{item.city}}</text>
  89. <text>{{item.area}}</text><text>{{item.address}}</text>
  90. </view>
  91. </view>
  92. <text class="iconfont icon-jiantouyou"></text>
  93. </view>
  94. <view class="two">
  95. <view class="two_1">
  96. <checkbox-group @change="toCheckbox">
  97. <label>
  98. <checkbox :value="item._id" :checked="item.checked" style="transform:scale(0.7)" />选择地址
  99. </label>
  100. </checkbox-group>
  101. </view>
  102. <view class="two_2">
  103. <text class="text" v-if="item.is_default=='1'">默认</text>
  104. <text @click="toDel(item)" class="iconfont icon-del"></text>
  105. </view>
  106. </view>
  107. </view>
  108. </uni-popup>
  109. </mobile-frame>
  110. </template>
  111. <script>
  112. export default {
  113. data() {
  114. return {
  115. user: {},
  116. key: '',
  117. info: {},
  118. shop: {
  119. money: 58,
  120. freight: 7
  121. },
  122. orderList: [{
  123. shop: '官方自营店',
  124. status: '1',
  125. url: [{
  126. name: "20220928155634.jpg",
  127. uri: "/files/point/20220928155634.jpg",
  128. url: "https://broadcast.waityou24.cn/files/point/20220928155634.jpg"
  129. }],
  130. name: '饮用水',
  131. price: 58,
  132. buy_num: 1,
  133. market_num: 1,
  134. money: 58,
  135. freight: 7
  136. }, {
  137. shop: '官方自营店',
  138. status: '1',
  139. url: [{
  140. name: "20220928155634.jpg",
  141. uri: "/files/point/20220928155634.jpg",
  142. url: "https://broadcast.waityou24.cn/files/point/20220928155634.jpg"
  143. }],
  144. name: '饮用水',
  145. price: 58,
  146. buy_num: 1,
  147. market_num: 1,
  148. money: 58,
  149. freight: 7
  150. }],
  151. // 收货地址
  152. addressList: [],
  153. };
  154. },
  155. onShow: function() {
  156. const that = this;
  157. that.watchLogin()
  158. },
  159. onLoad: async function(e) {
  160. const that = this;
  161. that.$set(that, `key`, e.key || '');
  162. },
  163. methods: {
  164. // 选择收货地址
  165. toChoose() {
  166. const that = this;
  167. that.$refs.popup.open();
  168. },
  169. // 是否选中
  170. toCheckbox(e) {
  171. const that = this;
  172. var addressList = that.addressList;
  173. var values = e.detail.value;
  174. for (var i = 0, lenI = addressList.length; i < lenI; ++i) {
  175. const item = addressList[i]
  176. if (values.includes(item._id)) {
  177. that.$set(item, 'checked', true)
  178. that.$set(that, `info`, item);
  179. } else {
  180. that.$set(item, 'checked', false)
  181. }
  182. }
  183. that.$refs.popup.close();
  184. },
  185. // 删除收货地址
  186. toDel(e) {
  187. const that = this;
  188. uni.showModal({
  189. title: '提示',
  190. content: '确定删除该地址吗?',
  191. success: async function(res) {
  192. if (res.confirm) {
  193. const arr = await that.$api(`/address/${e._id}`, 'DELETE');
  194. if (arr.errcode == '0') {
  195. uni.showToast({
  196. title: '删除信息成功',
  197. icon: 'none'
  198. })
  199. that.search();
  200. } else {
  201. uni.showToast({
  202. title: arr.errmsg,
  203. icon: 'none'
  204. })
  205. }
  206. }
  207. }
  208. });
  209. },
  210. // 提交订单
  211. toSubmit() {
  212. },
  213. // 监听用户是否登录
  214. watchLogin() {
  215. const that = this;
  216. uni.getStorage({
  217. key: 'token',
  218. success: function(res) {
  219. let user = that.$jwt(res.data);
  220. that.$set(that, `user`, user);
  221. that.search()
  222. },
  223. fail: function(err) {
  224. uni.reLaunch({
  225. url: `/pages/login/index`
  226. })
  227. }
  228. })
  229. },
  230. // 查询列表
  231. async search() {
  232. const that = this;
  233. let user = that.user;
  234. const res = await that.$api(`/address`, 'GET', {
  235. customer: user._id
  236. })
  237. if (res.errcode == '0') {
  238. that.$set(that, `addressList`, res.data);
  239. }
  240. },
  241. }
  242. }
  243. </script>
  244. <style lang="scss">
  245. .main {
  246. display: flex;
  247. flex-direction: column;
  248. width: 100vw;
  249. height: 100vh;
  250. .one {
  251. position: relative;
  252. flex-grow: 1;
  253. background-color: var(--f1Color);
  254. .one_1 {
  255. display: flex;
  256. justify-content: space-between;
  257. align-items: center;
  258. width: 100vw;
  259. padding: 2vw;
  260. border-bottom: 1vw dashed var(--fcColor);
  261. .address {
  262. flex-grow: 1;
  263. margin: 0 0 0 2vw;
  264. font-size: var(--font14Size);
  265. color: var(--f85Color);
  266. }
  267. .iconfont {
  268. font-size: var(--font20Szie);
  269. }
  270. .other {
  271. width: 82vw;
  272. padding: 0 2vw;
  273. .name {
  274. font-size: var(--font16Size);
  275. }
  276. .other_1 {
  277. font-size: var(--font14Size);
  278. color: var(--f85Color);
  279. text {
  280. margin: 0 1vw 0 0;
  281. }
  282. }
  283. }
  284. }
  285. .one_2 {
  286. margin: 2vw 0 0 0;
  287. .list {
  288. width: 100vw;
  289. margin: 2vw 0;
  290. .list_1 {
  291. padding: 2vw;
  292. background-color: var(--mainColor);
  293. border-bottom: 0.1vw solid var(--fcColor);
  294. text {
  295. padding: 0 0 0 1vw;
  296. }
  297. }
  298. .list_2 {
  299. padding: 2vw;
  300. display: flex;
  301. background-color: var(--mainColor);
  302. .l {
  303. width: 20vw;
  304. .image {
  305. width: 100%;
  306. height: 20vw;
  307. border-radius: 5px;
  308. }
  309. }
  310. .c {
  311. width: 60vw;
  312. padding: 0 2vw;
  313. }
  314. .r {
  315. width: 15vw;
  316. text-align: right;
  317. }
  318. }
  319. .list_3 {
  320. width: 96vw;
  321. padding: 2vw;
  322. background-color: var(--mainColor);
  323. .other {
  324. display: flex;
  325. justify-content: space-between;
  326. border-bottom: 0.1vw solid var(--fcColor);
  327. margin: 0 0 2vw 0;
  328. padding: 2vw 0;
  329. .other_1 {
  330. font-size: var(--font16Size);
  331. color: var(--f85Color);
  332. }
  333. .other_3 {
  334. flex-grow: 1;
  335. margin: 0 0 0 2vw;
  336. font-size: var(--font12Size);
  337. }
  338. text {
  339. padding: 0 1vw 0 0;
  340. font-size: var(--font20Szie);
  341. }
  342. }
  343. }
  344. }
  345. }
  346. }
  347. .two {
  348. display: flex;
  349. justify-content: space-between;
  350. border-top: 0.1vw solid var(--fcColor);
  351. .two_1 {
  352. display: flex;
  353. align-items: center;
  354. padding: 0 2vw;
  355. font-size: var(--font16Size);
  356. view:last-child {
  357. margin: 0 0 0 2vw;
  358. color: var(--ff0Color);
  359. font-weight: bold;
  360. }
  361. }
  362. .two_2 {
  363. padding: 3vw 4vw;
  364. color: var(--mainColor);
  365. font-size: var(--font16Size);
  366. background-color: var(--ff0Color);
  367. }
  368. }
  369. }
  370. .scroll-view {
  371. position: absolute;
  372. top: 0;
  373. left: 0;
  374. right: 0;
  375. bottom: 0;
  376. .list-scroll-view {
  377. display: flex;
  378. flex-direction: row;
  379. flex-wrap: wrap;
  380. }
  381. }
  382. .content {
  383. display: flex;
  384. flex-direction: column;
  385. background-color: var(--f1Color);
  386. .one {
  387. display: flex;
  388. justify-content: space-between;
  389. margin: 2vw 0 0 0;
  390. padding: 2vw;
  391. background-color: var(--mainColor);
  392. .name {
  393. font-size: var(--font16Size);
  394. }
  395. .address {
  396. font-size: var(--font14Size);
  397. }
  398. .iconfont {
  399. line-height: 15vw;
  400. font-size: var(--font20Szie);
  401. }
  402. }
  403. .two {
  404. display: flex;
  405. justify-content: space-between;
  406. border-top: 0.1vw solid var(--fcColor);
  407. padding: 2vw;
  408. background-color: var(--mainColor);
  409. font-size: var(--font14Size);
  410. .text {
  411. margin: 0 2vw 0 0;
  412. border: 0.1vw solid var(--fFB1Color);
  413. padding: 1vw;
  414. font-size: var(--font12Size);
  415. border-radius: 2vw;
  416. color: var(--fFB1Color);
  417. }
  418. }
  419. }
  420. </style>