applyFaHuo.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. {
  76. name: '微信支付',
  77. type: '0',
  78. account: '',
  79. image: '/static/image/me/weixin@2x.png'
  80. }
  81. // {
  82. // name:'支付宝支付',
  83. // type:'1',
  84. // account:'',
  85. // image:'/static/image/me/zhifubao@2x.png'
  86. // }
  87. ] //支付列表
  88. };
  89. },
  90. methods: {
  91. //申请发货
  92. applySubmit() {
  93. if (!this.applyAddress.address_id) return uni.showToast({ title: '请选择地址', icon: 'none' });
  94. let ids = [];
  95. this.applyList.forEach(item => {
  96. ids.push(item.record_id);
  97. });
  98. if (!this.flag) return;
  99. this.flag = false;
  100. this.$api.applyDelivery({ record_ids: ids.join(','), address_id: this.applyAddress.address_id }).then(res => {
  101. if (res.code === 1) {
  102. if (res.data.delivery_fee > 0) {
  103. if (this.payIndex == 0) {
  104. // #ifdef MP
  105. this.$http.post(res.data.wechat).then(res => {
  106. let da = res.jsConfig;
  107. let data = {
  108. // #ifdef MP
  109. timeStamp: da.timeStamp,
  110. // #endif
  111. nonceStr: da.nonceStr,
  112. package: da.package,
  113. signType: da.signType,
  114. paySign: da.paySign,
  115. success: function(res) {
  116. uni.showToast({ title: '支付成功' });
  117. setTimeout(() => {
  118. uni.redirectTo({ url: '/pages/me/wallet' });
  119. }, 800);
  120. },
  121. fail: () => {
  122. uni.showToast({ title: '支付失败' });
  123. }
  124. };
  125. console.log(data);
  126. wx.requestPayment(data);
  127. });
  128. // #endif
  129. }
  130. } else {
  131. // 跳转到支付页面
  132. uni.redirectTo({ url: '/pages/me/order?type=0' });
  133. }
  134. // uni.removeStorageSync('applyAddress')
  135. // uni.showToast({title:res.msg})
  136. // setTimeout(()=>{
  137. // uni.navigateBack()
  138. // },800)
  139. } else {
  140. this.flag = true;
  141. }
  142. });
  143. },
  144. //去选择地址
  145. selectAddress() {
  146. uni.navigateTo({ url: '/pages/me/address?type=1' });
  147. },
  148. //获取回收信息
  149. getApply() {
  150. this.$api.checkDeliveryInfo({ record_ids: this.id }).then(res => {
  151. if (res.code === 1) {
  152. this.applyList = res.data.order_info;
  153. this.totalPrice = res.data.total_delivery_fee;
  154. }
  155. });
  156. },
  157. //获取默认地址
  158. getAddress() {
  159. this.$api.myAddress({ is_default: 1 }).then(res => {
  160. if (res.code === 1) {
  161. if (res.data.length != 0) {
  162. this.applyAddress = res.data[0];
  163. }
  164. }
  165. });
  166. },
  167. changePay(index) {
  168. this.payIndex = index;
  169. }
  170. },
  171. onShow() {
  172. if (uni.getStorageSync('applyAddress')) {
  173. this.applyAddress = JSON.parse(uni.getStorageSync('applyAddress'));
  174. } else {
  175. this.getAddress();
  176. }
  177. },
  178. onLoad({ id }) {
  179. this.id = id;
  180. this.getApply();
  181. }
  182. };
  183. </script>
  184. <style lang="scss">
  185. .deposit_main_ul {
  186. margin-top: 20rpx;
  187. background: #ffffff;
  188. .deposit_main_li {
  189. padding: 30rpx 20rpx;
  190. .deposit_main_img {
  191. image {
  192. width: 50rpx;
  193. height: 50rpx;
  194. margin-right: 20rpx;
  195. }
  196. text {
  197. font-size: 28rpx;
  198. }
  199. }
  200. .deposit_main_li_select {
  201. width: 32rpx;
  202. height: 32rpx;
  203. }
  204. }
  205. }
  206. .apply {
  207. padding: 0 30rpx;
  208. padding-bottom: 60rpx;
  209. .apply_head_name {
  210. padding: 30rpx 0;
  211. font-size: 28rpx;
  212. font-weight: bold;
  213. }
  214. .apply_head_ipt {
  215. padding: 30rpx;
  216. border-radius: 10rpx;
  217. background: #ffffff;
  218. input {
  219. font-size: 28rpx;
  220. }
  221. image {
  222. width: 22rpx;
  223. height: 22rpx;
  224. }
  225. }
  226. .apply_head_address {
  227. .address_have_li_title {
  228. color: #666666;
  229. font-size: 28rpx;
  230. }
  231. .address_have_li_txt {
  232. font-size: 26rpx;
  233. margin: 20rpx 0;
  234. }
  235. .address_have_li_name {
  236. text {
  237. color: #999999;
  238. font-size: 30rpx;
  239. &:last-child {
  240. font-size: 28rpx;
  241. margin-left: 20rpx;
  242. }
  243. }
  244. }
  245. }
  246. }
  247. .apply_main_name {
  248. font-size: 28rpx;
  249. font-weight: bold;
  250. padding: 30rpx 0 20rpx 0;
  251. }
  252. .apply_main {
  253. padding-bottom: 98rpx;
  254. }
  255. .apply_main_li {
  256. margin-bottom: 20rpx;
  257. &:last-child {
  258. margin-bottom: 0;
  259. }
  260. .apply_main_li_box {
  261. padding: 30rpx;
  262. background: #ffffff;
  263. }
  264. border-radius: 20rpx;
  265. .apply_main_li_img {
  266. width: 168rpx;
  267. height: 168rpx;
  268. image {
  269. border-radius: 10rpx;
  270. }
  271. margin-right: 20rpx;
  272. }
  273. .apply_main_li_main {
  274. height: 168rpx;
  275. align-items: flex-start;
  276. flex-direction: column;
  277. }
  278. .apply_main_li_name {
  279. font-size: 28rpx;
  280. line-height: 36rpx;
  281. }
  282. .apply_main_li_time {
  283. color: #999999;
  284. }
  285. }
  286. .apply_order {
  287. padding: 0 30rpx 0 20rpx;
  288. border-radius: 10rpx;
  289. background: #ffffff;
  290. margin-top: 20rpx;
  291. .apply_order_li {
  292. padding: 30rpx 0;
  293. text {
  294. font-size: 26rpx;
  295. &:last-child {
  296. color: #999999;
  297. }
  298. }
  299. .red {
  300. color: #cf271b !important;
  301. }
  302. }
  303. }
  304. .apply_btn {
  305. color: #333333;
  306. font-size: 30rpx;
  307. font-weight: bold;
  308. height: 98rpx;
  309. margin-top: 212rpx;
  310. background: #ffffff;
  311. box-shadow: 0rpx 0rpx 121rpx 0rpx rgba(63, 52, 2, 0.12);
  312. border-radius: 10rpx;
  313. }
  314. .apply_footer {
  315. width: 100%;
  316. left: 0;
  317. bottom: 0;
  318. height: 98rpx;
  319. position: fixed;
  320. padding-left: 30rpx;
  321. background: #ffffff;
  322. .apply_footer_total {
  323. font-size: 28rpx;
  324. }
  325. .apply_footer_btn {
  326. width: 280rpx;
  327. height: 100%;
  328. color: #ffffff;
  329. font-size: 28rpx;
  330. background: -webkit-linear-gradient(0deg, #89f7fe 0%, #66a6ff 100%);
  331. }
  332. }
  333. </style>