applyFaHuo.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <view class="apply">
  3. <view class="apply_head">
  4. <view class="apply_head_name">收货人信息</view>
  5. <view class="apply_head_ipt flex" @click="selectAddress">
  6. <input type="text" disabled v-if="!applyAddress.address_id" placeholder="填写收货地址" placeholder-style="color:#999999" />
  7. <view class="apply_head_address" v-else>
  8. <view class="address_have_li_title">{{ applyAddress.province }} {{ applyAddress.city }} {{ applyAddress.area }}</view>
  9. <view class="address_have_li_txt">{{ applyAddress.detail }}</view>
  10. <view class="address_have_li_name flexs">
  11. <text>{{ applyAddress.username }}</text>
  12. <text>{{ applyAddress.mobile }}</text>
  13. </view>
  14. </view>
  15. <image src="/static/image/publice/jinruer@2x.png" mode=""></image>
  16. </view>
  17. </view>
  18. <view class="apply_main">
  19. <view class="apply_main_name">订单信息</view>
  20. <view class="apply_main_ul">
  21. <view class="apply_main_li " v-for="(item, index) in applyList" :key="index">
  22. <view class="apply_main_li_box flexs">
  23. <view class="apply_main_li_img"><image :src="item.goods_image" mode="aspectFill"></image></view>
  24. <view class="apply_main_li_main flex">
  25. <view class="apply_main_li_name">{{ item.goods_name }}</view>
  26. <view class="apply_main_li_time">开箱日期:{{ item.time }}</view>
  27. </view>
  28. </view>
  29. <view class="apply_order">
  30. <view class="apply_order_li flex">
  31. <text>付款金额</text>
  32. <text class="red">{{ item.pay_amount }}</text>
  33. </view>
  34. <view class="apply_order_li flex">
  35. <text>支付方式</text>
  36. <text>{{ item.pay_method }}</text>
  37. </view>
  38. <view class="apply_order_li flex">
  39. <text>运费</text>
  40. <text>{{ item.delivery_fee }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="deposit_main_ul">
  46. <view class="deposit_main_li flex" v-for="(item, index) in payList" :key="index" @click="changePay(item.type)">
  47. <view class="deposit_main_img flexs">
  48. <image :src="item.image" mode=""></image>
  49. <text>{{ item.name }}{{ item.account ? '(' + item.account + ')' : '' }}</text>
  50. </view>
  51. <view class="deposit_main_li_select">
  52. <image :src="item.type == payIndex ? '../../static/image/publice/xuanzhong1@2x.png' : '../../static/image/publice/weixuanzhong@2x.png'" mode=""></image>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="apply_footer flex">
  58. <view class="apply_footer_total">合计:¥{{ totalPrice }}</view>
  59. <view class="apply_footer_btn center" @click="applySubmit">申请发货</view>
  60. </view>
  61. <!-- <button class="apply_btn" hover-class="hover-view" @click="applySubmit">申请发货</button> -->
  62. </view>
  63. </template>
  64. <script>
  65. export default {
  66. data() {
  67. return {
  68. id: '', //回收ID
  69. flag: true, //
  70. totalPrice: '',
  71. applyList: [], //回收列表
  72. applyAddress: {}, //收货地址
  73. payIndex: 1, //支付方式
  74. payList: [
  75. // #ifndef APP-PLUS
  76. {
  77. name: '微信支付',
  78. type: '0',
  79. account: '',
  80. image: '/static/image/me/weixin@2x.png'
  81. },
  82. // #endif
  83. // #ifdef APP-PLUS
  84. {
  85. name: '支付宝支付',
  86. type: '1',
  87. account: '',
  88. image: '/static/image/me/zhifubao@2x.png'
  89. }
  90. // #endif
  91. ] //支付列表
  92. };
  93. },
  94. methods: {
  95. //申请发货
  96. applySubmit() {
  97. if (!this.applyAddress.address_id) return uni.showToast({ title: '请选择地址', icon: 'none' });
  98. let ids = [];
  99. this.applyList.forEach(item => {
  100. ids.push(item.record_id);
  101. });
  102. if (!this.flag) return;
  103. this.flag = false;
  104. this.$api.applyDelivery({ record_ids: ids.join(','), address_id: this.applyAddress.address_id }).then(res => {
  105. if (res.code === 1) {
  106. if (res.data.delivery_fee > 0) {
  107. if (this.payIndex == 0) {
  108. // #ifdef MP
  109. this.$http.post(res.data.wechat).then(res => {
  110. let da = res.jsConfig;
  111. let data = {
  112. // #ifdef MP
  113. timeStamp: da.timeStamp,
  114. // #endif
  115. nonceStr: da.nonceStr,
  116. package: da.package,
  117. signType: da.signType,
  118. paySign: da.paySign,
  119. success: function(res) {
  120. uni.showToast({ title: '支付成功' });
  121. setTimeout(() => {
  122. uni.redirectTo({ url: '/pages/me/wallet' });
  123. }, 800);
  124. },
  125. fail: () => {
  126. uni.showToast({ title: '支付失败' });
  127. }
  128. };
  129. console.log(data);
  130. wx.requestPayment(data);
  131. });
  132. // #endif
  133. } else if (this.payIndex == 1) {
  134. res.data.alipay = res.data.alipay.slice(28, res.data.alipay.length);
  135. this.$http.post(res.data.alipay).then(res => {
  136. uni.requestPayment({
  137. provider: 'alipay',
  138. orderInfo: res,
  139. success: res => {
  140. console.log(res);
  141. uni.showToast({
  142. title: '支付成功',
  143. duration: 2000
  144. });
  145. },
  146. fail: e => {
  147. console.log(e);
  148. },
  149. complete: () => {}
  150. });
  151. });
  152. }
  153. } else {
  154. // 跳转到支付页面
  155. uni.redirectTo({ url: '/pages/me/order?type=0' });
  156. }
  157. // uni.removeStorageSync('applyAddress')
  158. // uni.showToast({title:res.msg})
  159. // setTimeout(()=>{
  160. // uni.navigateBack()
  161. // },800)
  162. } else {
  163. this.flag = true;
  164. }
  165. });
  166. },
  167. //去选择地址
  168. selectAddress() {
  169. uni.navigateTo({ url: '/pages/me/address?type=1' });
  170. },
  171. //获取回收信息
  172. getApply() {
  173. this.$api.checkDeliveryInfo({ record_ids: this.id }).then(res => {
  174. if (res.code === 1) {
  175. this.applyList = res.data.order_info;
  176. this.totalPrice = res.data.total_delivery_fee;
  177. }
  178. });
  179. },
  180. //获取默认地址
  181. getAddress() {
  182. this.$api.myAddress({ is_default: 1 }).then(res => {
  183. if (res.code === 1) {
  184. if (res.data.length != 0) {
  185. this.applyAddress = res.data[0];
  186. }
  187. }
  188. });
  189. },
  190. changePay(index) {
  191. this.payIndex = index;
  192. }
  193. },
  194. onShow() {
  195. if (uni.getStorageSync('applyAddress')) {
  196. this.applyAddress = JSON.parse(uni.getStorageSync('applyAddress'));
  197. } else {
  198. this.getAddress();
  199. }
  200. },
  201. onLoad({ id }) {
  202. this.id = id;
  203. this.getApply();
  204. }
  205. };
  206. </script>
  207. <style lang="scss">
  208. .deposit_main_ul {
  209. margin-top: 20rpx;
  210. background: #ffffff;
  211. .deposit_main_li {
  212. padding: 30rpx 20rpx;
  213. .deposit_main_img {
  214. image {
  215. width: 50rpx;
  216. height: 50rpx;
  217. margin-right: 20rpx;
  218. }
  219. text {
  220. font-size: 28rpx;
  221. }
  222. }
  223. .deposit_main_li_select {
  224. width: 32rpx;
  225. height: 32rpx;
  226. }
  227. }
  228. }
  229. .apply {
  230. padding: 0 30rpx;
  231. padding-bottom: 60rpx;
  232. .apply_head_name {
  233. padding: 30rpx 0;
  234. font-size: 28rpx;
  235. font-weight: bold;
  236. }
  237. .apply_head_ipt {
  238. padding: 30rpx;
  239. border-radius: 10rpx;
  240. background: #ffffff;
  241. input {
  242. font-size: 28rpx;
  243. }
  244. image {
  245. width: 22rpx;
  246. height: 22rpx;
  247. }
  248. }
  249. .apply_head_address {
  250. .address_have_li_title {
  251. color: #666666;
  252. font-size: 28rpx;
  253. }
  254. .address_have_li_txt {
  255. font-size: 26rpx;
  256. margin: 20rpx 0;
  257. }
  258. .address_have_li_name {
  259. text {
  260. color: #999999;
  261. font-size: 30rpx;
  262. &:last-child {
  263. font-size: 28rpx;
  264. margin-left: 20rpx;
  265. }
  266. }
  267. }
  268. }
  269. }
  270. .apply_main_name {
  271. font-size: 28rpx;
  272. font-weight: bold;
  273. padding: 30rpx 0 20rpx 0;
  274. }
  275. .apply_main {
  276. padding-bottom: 98rpx;
  277. }
  278. .apply_main_li {
  279. margin-bottom: 20rpx;
  280. &:last-child {
  281. margin-bottom: 0;
  282. }
  283. .apply_main_li_box {
  284. padding: 30rpx;
  285. background: #ffffff;
  286. }
  287. border-radius: 20rpx;
  288. .apply_main_li_img {
  289. width: 168rpx;
  290. height: 168rpx;
  291. image {
  292. border-radius: 10rpx;
  293. }
  294. margin-right: 20rpx;
  295. }
  296. .apply_main_li_main {
  297. height: 168rpx;
  298. align-items: flex-start;
  299. flex-direction: column;
  300. }
  301. .apply_main_li_name {
  302. font-size: 28rpx;
  303. line-height: 36rpx;
  304. }
  305. .apply_main_li_time {
  306. color: #999999;
  307. }
  308. }
  309. .apply_order {
  310. padding: 0 30rpx 0 20rpx;
  311. border-radius: 10rpx;
  312. background: #ffffff;
  313. margin-top: 20rpx;
  314. .apply_order_li {
  315. padding: 30rpx 0;
  316. text {
  317. font-size: 26rpx;
  318. &:last-child {
  319. color: #999999;
  320. }
  321. }
  322. .red {
  323. color: #cf271b !important;
  324. }
  325. }
  326. }
  327. .apply_btn {
  328. color: #333333;
  329. font-size: 30rpx;
  330. font-weight: bold;
  331. height: 98rpx;
  332. margin-top: 212rpx;
  333. background: #ffffff;
  334. box-shadow: 0rpx 0rpx 121rpx 0rpx rgba(63, 52, 2, 0.12);
  335. border-radius: 10rpx;
  336. }
  337. .apply_footer {
  338. width: 100%;
  339. left: 0;
  340. bottom: 0;
  341. height: 98rpx;
  342. position: fixed;
  343. padding-left: 30rpx;
  344. background: #ffffff;
  345. .apply_footer_total {
  346. font-size: 28rpx;
  347. }
  348. .apply_footer_btn {
  349. width: 280rpx;
  350. height: 100%;
  351. color: #ffffff;
  352. font-size: 28rpx;
  353. background: -webkit-linear-gradient(0deg, #89f7fe 0%, #66a6ff 100%);
  354. }
  355. }
  356. </style>