orderConfirm.vue 8.3 KB

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