index.vue 11 KB

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