orderConfirm.vue 7.6 KB

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