order.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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>
  49. </view>
  50. <view class="one_3">
  51. <view class="other">
  52. <view class="other_1">配送方式</view>
  53. <view class="other_2"><text class="iconfont icon-duihao"></text>快递配送</view>
  54. </view>
  55. <view class="other">
  56. <view class="other_1">运费</view>
  57. <view class="other_2" v-if="!shop.freight==0">¥{{shop.freight}}</view>
  58. <view class="other_2" v-else>包邮</view>
  59. </view>
  60. <view class="other">
  61. <view class="other_1">订单备注</view>
  62. <view class="other_3">
  63. <input type="text" v-model="shop.remarks" placeholder="选填,可填写您与卖家达成一致的要求" />
  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. id: {},
  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, `id`, e.id || '');
  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. 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: 96vw;
  289. padding: 0 2vw;
  290. margin: 2vw 0;
  291. .list_1 {
  292. padding: 2vw;
  293. background-color: var(--mainColor);
  294. border-bottom: 0.1vw solid var(--fcColor);
  295. text {
  296. padding: 0 0 0 1vw;
  297. }
  298. }
  299. .list_2 {
  300. padding: 2vw;
  301. display: flex;
  302. background-color: var(--mainColor);
  303. .l {
  304. width: 20vw;
  305. .image {
  306. width: 100%;
  307. height: 20vw;
  308. border-radius: 5px;
  309. }
  310. }
  311. .c {
  312. width: 60vw;
  313. padding: 0 2vw;
  314. }
  315. .r {
  316. width: 15vw;
  317. text-align: right;
  318. }
  319. }
  320. }
  321. }
  322. .one_3 {
  323. width: 96vw;
  324. margin: 2vw 0 0 0;
  325. padding: 2vw;
  326. background-color: var(--mainColor);
  327. .other {
  328. display: flex;
  329. justify-content: space-between;
  330. border-bottom: 0.1vw solid var(--fcColor);
  331. margin: 0 0 2vw 0;
  332. padding: 2vw 0;
  333. .other_1 {
  334. font-size: var(--font16Size);
  335. color: var(--f85Color);
  336. }
  337. .other_3 {
  338. flex-grow: 1;
  339. margin: 0 0 0 2vw;
  340. font-size: var(--font12Size);
  341. }
  342. text {
  343. padding: 0 1vw 0 0;
  344. font-size: var(--font20Szie);
  345. }
  346. }
  347. }
  348. }
  349. .two {
  350. display: flex;
  351. justify-content: space-between;
  352. border-top: 0.1vw solid var(--fcColor);
  353. .two_1 {
  354. display: flex;
  355. align-items: center;
  356. padding: 0 2vw;
  357. font-size: var(--font16Size);
  358. view:last-child {
  359. margin: 0 0 0 2vw;
  360. color: var(--ff0Color);
  361. font-weight: bold;
  362. }
  363. }
  364. .two_2 {
  365. padding: 3vw 4vw;
  366. color: var(--mainColor);
  367. font-size: var(--font16Size);
  368. background-color: var(--ff0Color);
  369. }
  370. }
  371. }
  372. .scroll-view {
  373. position: absolute;
  374. top: 0;
  375. left: 0;
  376. right: 0;
  377. bottom: 0;
  378. .list-scroll-view {
  379. display: flex;
  380. flex-direction: row;
  381. flex-wrap: wrap;
  382. }
  383. }
  384. .content {
  385. display: flex;
  386. flex-direction: column;
  387. background-color: var(--f1Color);
  388. .one {
  389. display: flex;
  390. justify-content: space-between;
  391. margin: 2vw 0 0 0;
  392. padding: 2vw;
  393. background-color: var(--mainColor);
  394. .name {
  395. font-size: var(--font16Size);
  396. }
  397. .address {
  398. font-size: var(--font14Size);
  399. }
  400. .iconfont {
  401. line-height: 15vw;
  402. font-size: var(--font20Szie);
  403. }
  404. }
  405. .two {
  406. display: flex;
  407. justify-content: space-between;
  408. border-top: 0.1vw solid var(--fcColor);
  409. padding: 2vw;
  410. background-color: var(--mainColor);
  411. font-size: var(--font14Size);
  412. .text {
  413. margin: 0 2vw 0 0;
  414. border: 0.1vw solid var(--fFB1Color);
  415. padding: 1vw;
  416. font-size: var(--font12Size);
  417. border-radius: 2vw;
  418. color: var(--fFB1Color);
  419. }
  420. }
  421. }
  422. </style>