order.vue 9.7 KB

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