index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  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" @click="toChoose">
  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 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>{{shopInfo.name}}</text>
  27. </view>
  28. </view>
  29. <view class="list_2">
  30. <view class="l">
  31. <image class="image" :src="orderInfo.file&&orderInfo.file.length>0?orderInfo.file[0].url:''" mode=""></image>
  32. </view>
  33. <view class="c">
  34. <view class="name">
  35. {{orderInfo.name}}
  36. </view>
  37. </view>
  38. <view class="r">
  39. <view class="price">
  40. {{orderInfo.cost}}
  41. </view>
  42. <view class="num">
  43. ×{{buy_num}}
  44. </view>
  45. </view>
  46. </view>
  47. <view class="list_3">
  48. <view class="other">
  49. <view class="other_1">配送方式</view>
  50. <view class="other_2"><text class="iconfont icon-duihao"></text>快递配送</view>
  51. </view>
  52. <view class="other">
  53. <view class="other_1">运费</view>
  54. <view class="other_2">包邮</view>
  55. </view>
  56. <view class="other">
  57. <view class="other_1">订单备注</view>
  58. <view class="other_3">
  59. <input type="text" v-model="remarks" placeholder="选填,可填写您与卖家达成一致的要求" />
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </scroll-view>
  67. </view>
  68. <view class="two">
  69. <view class="two_1">
  70. <view>尊荣:</view>
  71. <view>{{costTotal}}</view>
  72. </view>
  73. <view class="two_2">
  74. <text @click="toSubmit">尊荣支付</text>
  75. </view>
  76. </view>
  77. </view>
  78. <uni-popup ref="popup" background-color="#fff" type="bottom">
  79. <view class="popup">
  80. <scroll-view scroll-y="true" class="scroll-view">
  81. <view class="list" 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. 选择地址
  100. </label>
  101. </checkbox-group>
  102. </view>
  103. <view class="two_2">
  104. <text class="text" v-if="item.is_default=='1'">默认</text>
  105. <text @click="toDel(item)" class="iconfont icon-del"></text>
  106. </view>
  107. </view>
  108. </view>
  109. </scroll-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. // 商品详情
  122. orderInfo: {},
  123. // 店铺详情
  124. shopInfo: {},
  125. // 总尊荣
  126. costTotal: 0,
  127. // 购买数量
  128. buy_num: 0,
  129. // 收货地址
  130. addressList: [],
  131. // 备注
  132. remarks: '',
  133. };
  134. },
  135. onLoad: async function(e) {
  136. const that = this;
  137. that.$set(that, `key`, e.key || '');
  138. that.watchLogin()
  139. },
  140. methods: {
  141. // 监听用户是否登录
  142. watchLogin() {
  143. const that = this;
  144. uni.getStorage({
  145. key: 'token',
  146. success: function(res) {
  147. let user = that.$jwt(res.data);
  148. that.$set(that, `user`, user);
  149. that.search()
  150. },
  151. fail: function(err) {
  152. uni.reLaunch({
  153. url: `/pages/login/index`
  154. })
  155. }
  156. })
  157. },
  158. // 查询列表
  159. async search() {
  160. const that = this;
  161. let user = that.user;
  162. const res = await that.$api(`/address`, 'GET', {
  163. customer: user._id
  164. })
  165. if (res.errcode == '0') {
  166. that.$set(that, `addressList`, res.data.reverse());
  167. }
  168. const arr = await that.$api(`/zrOrder/toMakeOrder`, 'POST', {
  169. key: that.key
  170. }, `integral`)
  171. if (arr.errcode == '0') {
  172. that.$set(that, `address`, arr.data.address);
  173. that.$set(that, `orderInfo`, arr.data.goods);
  174. that.$set(that, `costTotal`, arr.data.costTotal);
  175. that.$set(that, `shopInfo`, arr.data.shop);
  176. that.$set(that, `buy_num`, arr.data.buy_num);
  177. }
  178. },
  179. // 选择收货地址
  180. toChoose() {
  181. const that = this;
  182. if (that.addressList.length > 0) {
  183. that.$refs.popup.open();
  184. } else {
  185. uni.showToast({
  186. title: `暂无收货地址`,
  187. icon: 'none'
  188. })
  189. }
  190. },
  191. // 是否选中
  192. toCheckbox(e) {
  193. const that = this;
  194. var addressList = that.addressList;
  195. var values = e.detail.value;
  196. for (var i = 0, lenI = addressList.length; i < lenI; ++i) {
  197. const item = addressList[i]
  198. if (values.includes(item._id)) {
  199. that.$set(item, 'checked', true)
  200. that.$set(that, `address`, item);
  201. } else {
  202. that.$set(item, 'checked', false)
  203. }
  204. }
  205. that.$refs.popup.close();
  206. },
  207. // 删除收货地址
  208. toDel(e) {
  209. const that = this;
  210. uni.showModal({
  211. title: '提示',
  212. content: '确定删除该地址吗?',
  213. success: async function(res) {
  214. if (res.confirm) {
  215. const arr = await that.$api(`/address/${e._id}`, 'DELETE');
  216. if (arr.errcode == '0') {
  217. uni.showToast({
  218. title: '删除信息成功',
  219. icon: 'none'
  220. })
  221. that.search();
  222. } else {
  223. uni.showToast({
  224. title: arr.errmsg,
  225. icon: 'none'
  226. })
  227. }
  228. }
  229. }
  230. });
  231. },
  232. // 提交订单
  233. async toSubmit() {
  234. const that = this;
  235. if (that.address) {
  236. uni.showModal({
  237. title: '提示',
  238. content: '确定兑换该商品吗?',
  239. success: async function(res) {
  240. if (res.confirm) {
  241. let data = {
  242. address: that.address._id,
  243. shop: that.shopInfo._id,
  244. goods: that.orderInfo._id,
  245. buy_num: that.buy_num,
  246. remarks: that.remarks
  247. }
  248. const arr = await that.$api(`/zrOrder`, `POST`, data, `integral`)
  249. if (arr.errcode == '0') {
  250. uni.hideLoading();
  251. uni.showToast({
  252. title: arr.data.errmsg || '兑换成功',
  253. icon: 'none'
  254. })
  255. uni.reLaunch({
  256. url: `/pagesIntegral/record/index`
  257. })
  258. } else {
  259. uni.showToast({
  260. title: arr.data.errmsg || '兑换失败!',
  261. icon: 'none'
  262. })
  263. }
  264. }
  265. }
  266. });
  267. } else {
  268. uni.showToast({
  269. title: `没有收货地址`,
  270. icon: 'none'
  271. })
  272. }
  273. }
  274. }
  275. }
  276. </script>
  277. <style lang="scss">
  278. .main {
  279. display: flex;
  280. flex-direction: column;
  281. width: 100vw;
  282. height: 100vh;
  283. .one {
  284. position: relative;
  285. flex-grow: 1;
  286. background-color: var(--f1Color);
  287. .one_1 {
  288. display: flex;
  289. justify-content: space-between;
  290. align-items: center;
  291. width: 100vw;
  292. padding: 2vw;
  293. border-bottom: 1vw dashed var(--fcColor);
  294. .address {
  295. flex-grow: 1;
  296. margin: 0 0 0 2vw;
  297. font-size: var(--font14Size);
  298. color: var(--f85Color);
  299. }
  300. .iconfont {
  301. font-size: var(--font20Szie);
  302. }
  303. .other {
  304. width: 82vw;
  305. padding: 0 2vw;
  306. .name {
  307. font-size: var(--font16Size);
  308. }
  309. .other_1 {
  310. font-size: var(--font14Size);
  311. color: var(--f85Color);
  312. text {
  313. margin: 0 1vw 0 0;
  314. }
  315. }
  316. }
  317. }
  318. .one_2 {
  319. margin: 2vw 0 0 0;
  320. .list {
  321. width: 100vw;
  322. margin: 2vw 0;
  323. .list_1 {
  324. padding: 2vw;
  325. background-color: var(--mainColor);
  326. border-bottom: 0.1vw solid var(--fcColor);
  327. text {
  328. padding: 0 0 0 1vw;
  329. }
  330. }
  331. .list_2 {
  332. padding: 2vw;
  333. display: flex;
  334. background-color: var(--mainColor);
  335. .l {
  336. width: 20vw;
  337. .image {
  338. width: 100%;
  339. height: 20vw;
  340. border-radius: 5px;
  341. }
  342. }
  343. .c {
  344. width: 60vw;
  345. padding: 0 2vw;
  346. }
  347. .r {
  348. width: 15vw;
  349. text-align: right;
  350. .price {
  351. color: var(--fFB1Color);
  352. }
  353. }
  354. }
  355. .list_3 {
  356. width: 96vw;
  357. padding: 2vw;
  358. background-color: var(--mainColor);
  359. .other {
  360. display: flex;
  361. justify-content: space-between;
  362. border-bottom: 0.1vw solid var(--fcColor);
  363. margin: 0 0 2vw 0;
  364. padding: 2vw 0;
  365. .other_1 {
  366. font-size: var(--font16Size);
  367. color: var(--f85Color);
  368. }
  369. .other_3 {
  370. flex-grow: 1;
  371. margin: 0 0 0 2vw;
  372. font-size: var(--font12Size);
  373. }
  374. text {
  375. padding: 0 1vw 0 0;
  376. font-size: var(--font20Szie);
  377. }
  378. }
  379. }
  380. }
  381. .other {
  382. display: flex;
  383. justify-content: space-between;
  384. background-color: var(--mainColor);
  385. border-bottom: 0.1vw solid var(--fcColor);
  386. margin: 0 0 2vw 0;
  387. width: 96vw;
  388. padding: 2vw;
  389. .other_1 {
  390. font-size: var(--font16Size);
  391. color: var(--f85Color);
  392. }
  393. .other_3 {
  394. flex-grow: 1;
  395. margin: 0 0 0 2vw;
  396. font-size: var(--font12Size);
  397. }
  398. text {
  399. padding: 0 1vw 0 0;
  400. font-size: var(--font20Szie);
  401. }
  402. }
  403. }
  404. }
  405. .two {
  406. display: flex;
  407. justify-content: space-between;
  408. border-top: 0.1vw solid var(--fcColor);
  409. .two_1 {
  410. display: flex;
  411. align-items: center;
  412. padding: 0 2vw;
  413. font-size: var(--font16Size);
  414. view:last-child {
  415. margin: 0 0 0 2vw;
  416. color: var(--fFB1Color);
  417. font-weight: bold;
  418. }
  419. }
  420. .two_2 {
  421. padding: 3vw 4vw;
  422. color: var(--mainColor);
  423. font-size: var(--font16Size);
  424. background-color: #6A5ACD;
  425. }
  426. }
  427. }
  428. .scroll-view {
  429. position: absolute;
  430. top: 0;
  431. left: 0;
  432. right: 0;
  433. bottom: 0;
  434. .list-scroll-view {
  435. display: flex;
  436. flex-direction: row;
  437. flex-wrap: wrap;
  438. }
  439. }
  440. .popup {
  441. display: flex;
  442. flex-direction: column;
  443. height: 100vw;
  444. overflow-x: hidden;
  445. background-color: var(--f5Color);
  446. padding: 2vw;
  447. .list {
  448. .one {
  449. display: flex;
  450. justify-content: space-between;
  451. margin: 2vw 0 0 0;
  452. padding: 2vw;
  453. background-color: var(--mainColor);
  454. .name {
  455. font-size: var(--font16Size);
  456. }
  457. .address {
  458. font-size: var(--font14Size);
  459. }
  460. .iconfont {
  461. line-height: 15vw;
  462. font-size: var(--font20Szie);
  463. }
  464. }
  465. .two {
  466. display: flex;
  467. justify-content: space-between;
  468. border-top: 0.1vw solid var(--fcColor);
  469. padding: 2vw;
  470. background-color: var(--mainColor);
  471. font-size: var(--font14Size);
  472. .text {
  473. margin: 0 2vw 0 0;
  474. border: 0.1vw solid var(--fFB1Color);
  475. padding: 1vw;
  476. font-size: var(--font12Size);
  477. border-radius: 2vw;
  478. color: var(--fFB1Color);
  479. }
  480. }
  481. }
  482. }
  483. </style>