order.vue 8.9 KB

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