orderConfirm.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <view class="container">
  3. <view class="list">
  4. <view class="card" style="height: 120rpx; align-items: center" @click="toAddress" v-if="!addressId">
  5. <view class="row">
  6. <view class="left">
  7. <image
  8. class="icon"
  9. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/orderConfirm/icon1.png'"
  10. mode="widthFix"
  11. ></image>
  12. <span class="text1" style="margin-left: 10rpx">添加地址</span>
  13. </view>
  14. <view class="">
  15. <image
  16. class="icon"
  17. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/orderConfirm/icon2.png'"
  18. mode="widthFix"
  19. ></image>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="card" style="height: 120rpx; align-items: center" v-else @click="toAddress">
  24. <view class="row">
  25. <view>
  26. {{ address.name }}
  27. </view>
  28. <view>
  29. {{ address.tel }}
  30. </view>
  31. </view>
  32. <view class="row" style="margin-top: 10rpx">
  33. <view style="font-size: 24rpx">
  34. {{ address.province }}{{ address.city }}{{ address.county }}{{ address.addressDetail }}
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="list">
  40. <view class="card" v-for="(item, index) in list">
  41. <view class="row" style="margin-top: 20rpx">
  42. <view class="left">
  43. <image class="img" :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/ka.jpeg'" mode="aspectFill"></image>
  44. </view>
  45. <view class="right" style="font-size: 28rpx">
  46. <view class="row title">
  47. {{ item.prizeName }}
  48. </view>
  49. <view class="row text">获得时间:{{ item.creatTime }}</view>
  50. <!-- <view class="row" style="color: #FF2C43;">
  51. 回收积分:{{ item.integral }}
  52. <span class="status">{{ item.prizeStatus }}</span>
  53. </view> -->
  54. <!-- <view class="row button">
  55. <span></span>
  56. <span>
  57. <image style="width: 88rpx;" :src="'https://file.rongcyl.cn/festatic/bkm/imgv2' + /knapsack/button5.png" mode="widthFix"></image>
  58. </span>
  59. </view> -->
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="bottom">
  65. <view class="left">
  66. <view class="text">
  67. 共计:
  68. <span style="color: #000">{{ list.length }}</span>
  69. </view>
  70. </view>
  71. <view class="right">
  72. <image
  73. class="button"
  74. @click="clickSubmit"
  75. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/orderConfirm/button.png'"
  76. mode="heightFix"
  77. ></image>
  78. </view>
  79. </view>
  80. <uni-popup ref="popup" type="bottom" background-color="#fff" safe-area>
  81. <view class="popupContent">
  82. <view class="title">发货须知</view>
  83. <view class="text">
  84. 1.平台默认使用圆通物流,满5件国内包邮新疆、内蒙、港澳台除外),小于5件需支付15元邮费。申请发货后7-10个工作日发出
  85. </view>
  86. <view class="text">2.需要发其他快递请联系客服,高价卡建议联系客服进行顺丰保价。</view>
  87. <view class="text2">
  88. 运费:
  89. <view class="price" v-if="this.list.length >= 5">¥0</view>
  90. <view class="price" v-else>¥15</view>
  91. </view>
  92. <image
  93. class="button"
  94. @click="payment"
  95. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/orderConfirm/button2.png'"
  96. mode="heightFix"
  97. ></image>
  98. </view>
  99. </uni-popup>
  100. </view>
  101. </template>
  102. <script>
  103. import { packagePrizeIdsListApi, prizeOrderApi } from '@/api/knapsack.js'
  104. import { addressDetailApi, addressDefaultDetailApi } from '@/api/address.js'
  105. export default {
  106. data() {
  107. return {
  108. ids: [],
  109. list: [],
  110. address: {},
  111. addressId: '',
  112. }
  113. },
  114. onLoad(query) {
  115. this.getDefaultAddress()
  116. let orderConfirmIds = getApp().globalData.orderConfirmIds
  117. if (orderConfirmIds.length > 0) {
  118. this.ids = orderConfirmIds
  119. this.getList()
  120. }
  121. if (query.addressId) {
  122. this.addressId = query.addressId
  123. this.geAddress()
  124. }
  125. // this.$refs.popup.open('bottom')
  126. },
  127. methods: {
  128. getList() {
  129. packagePrizeIdsListApi(this.ids).then(res => {
  130. console.log(res, '商品')
  131. this.list = res.data
  132. })
  133. },
  134. // 获取默认地址
  135. getDefaultAddress() {
  136. addressDefaultDetailApi().then(res => {
  137. console.log(res, '默认地址')
  138. if (res.data) {
  139. this.address = res.data
  140. this.addressId = res.data.id
  141. }
  142. })
  143. },
  144. // 获取地址
  145. geAddress() {
  146. let params = {
  147. id: this.addressId,
  148. }
  149. addressDetailApi(params).then(res => {
  150. console.log(res, '选中的地址')
  151. if (res.data) {
  152. this.address = res.data
  153. }
  154. })
  155. },
  156. // 去选择地址
  157. toAddress() {
  158. getApp().globalData.selectAddrss = true
  159. this.$navigateTo('/pages/addressManage/addressManage')
  160. },
  161. clickSubmit() {
  162. if (!this.addressId) {
  163. wx.showToast({
  164. title: '请选则收货地址。',
  165. icon: 'none',
  166. })
  167. return
  168. }
  169. this.$refs.popup.open('bottom')
  170. },
  171. payment() {
  172. let param = {
  173. addressId: this.addressId,
  174. prizeIdList: this.ids,
  175. }
  176. let _this = this
  177. prizeOrderApi(param).then(res => {
  178. console.log(res, 'res')
  179. if (res.data.orderStatus == 201) {
  180. wx.showToast({
  181. title: '下单成功。',
  182. icon: 'success',
  183. })
  184. wx.switchTab({
  185. url: '/pages/knapsack/knapsack',
  186. })
  187. return
  188. }
  189. _this.wxPayment(res.data)
  190. })
  191. },
  192. close() {
  193. this.$refs.popup.close()
  194. },
  195. wxPayment(data) {
  196. let _this = this
  197. wx.requestPayment({
  198. timeStamp: data.timeStamp,
  199. nonceStr: data.nonceStr,
  200. package: data.packageValue,
  201. signType: data.signType,
  202. paySign: data.paySign,
  203. success: function (res) {
  204. console.log(res, '支付过程成功')
  205. wx.showToast({
  206. title: '支付成功。',
  207. icon: 'success',
  208. })
  209. _this.close()
  210. wx.navigateBack({
  211. delta: 1,
  212. })
  213. },
  214. fail: function (res) {
  215. console.log('支付过程失败')
  216. // util.showErrorToast('支付失败');
  217. },
  218. complete: function (res) {
  219. console.log('支付过程结束')
  220. },
  221. })
  222. },
  223. },
  224. }
  225. </script>
  226. <style scoped lang="scss">
  227. .list {
  228. padding: 20rpx;
  229. .swipeLeft {
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. width: 80rpx;
  234. .radio {
  235. transform: scale(0.8);
  236. }
  237. }
  238. .card {
  239. margin-bottom: 20rpx;
  240. border-radius: 16rpx;
  241. background: #fff;
  242. padding: 20rpx;
  243. display: flex;
  244. flex-wrap: wrap;
  245. .row {
  246. display: flex;
  247. justify-content: space-between;
  248. width: 100%;
  249. .left {
  250. display: flex;
  251. align-items: center;
  252. .photo {
  253. margin-right: 10rpx;
  254. width: 60rpx;
  255. height: 60rpx;
  256. border-radius: 50%;
  257. }
  258. .name {
  259. font-size: 28rpx;
  260. font-weight: 600;
  261. }
  262. .img {
  263. width: 200rpx;
  264. height: 200rpx;
  265. border-radius: 4rpx;
  266. margin-right: 20rpx;
  267. }
  268. }
  269. .right {
  270. flex: 1;
  271. .row {
  272. margin-bottom: 10rpx;
  273. }
  274. .title {
  275. font-size: 32rpx;
  276. font-weight: 600;
  277. }
  278. }
  279. .icon {
  280. width: 32rpx;
  281. }
  282. .text1 {
  283. color: #666666;
  284. font-size: 24rpx;
  285. }
  286. }
  287. }
  288. }
  289. .bottom {
  290. background: #fff;
  291. position: fixed;
  292. bottom: 0;
  293. display: flex;
  294. justify-content: space-between;
  295. width: calc(100% - 40rpx);
  296. padding: 20rpx 20rpx 60rpx 20rpx;
  297. .left {
  298. display: flex;
  299. justify-content: center;
  300. align-items: center;
  301. .text {
  302. color: #999;
  303. font-size: 28rpx;
  304. margin-left: 20rpx;
  305. }
  306. .radio1 {
  307. width: 40rpx;
  308. height: 40rpx;
  309. }
  310. .radio2 {
  311. width: 36rpx;
  312. height: 36rpx;
  313. }
  314. }
  315. .right {
  316. display: flex;
  317. .button {
  318. height: 60rpx;
  319. }
  320. }
  321. }
  322. .popupContent {
  323. .title {
  324. text-align: center;
  325. padding: 30rpx;
  326. font-weight: 600;
  327. }
  328. .text {
  329. padding: 20rpx 60rpx;
  330. font-size: 28rpx;
  331. }
  332. .text2 {
  333. padding: 20rpx;
  334. display: flex;
  335. justify-content: flex-end;
  336. .price {
  337. font-size: 28rpx;
  338. font-weight: 600;
  339. color: #ff2c43;
  340. }
  341. }
  342. .button {
  343. margin: 40rpx auto;
  344. height: 80rpx;
  345. }
  346. }
  347. </style>