applyFaHuo.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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 == 2) {
  104. this.$http.post(res.data.wechat).then(res => {
  105. if (res.code === 1) {
  106. WeixinJSBridge.invoke(
  107. 'getBrandWCPayRequest',
  108. {
  109. appId: res.data.appId, //公众号ID,由商户传入
  110. timeStamp: res.data.timeStamp, //时间戳,自1970年以来的秒数
  111. nonceStr: res.data.nonceStr, //随机串
  112. package: res.data.package,
  113. signType: res.data.signType, //微信签名方式:
  114. paySign: res.data.paySign //微信签名
  115. },
  116. function(res) {
  117. if (res.err_msg == 'get_brand_wcpay_request:ok') {
  118. uni.showToast({ title: '支付成功' });
  119. setTimeout(() => {
  120. uni.redirectTo({ url: '/pages/me/order?type=0' });
  121. }, 800);
  122. }
  123. }
  124. );
  125. } else if (res.code === 403) {
  126. }
  127. });
  128. } else {
  129. location.href = res.data[this.payIndex == 0 ? 'wechat' : 'alipay'] + '?token=' + uni.getStorageSync('token');
  130. }
  131. } else {
  132. // 跳转到支付页面
  133. uni.redirectTo({ url: '/pages/me/order?type=0' });
  134. }
  135. // uni.removeStorageSync('applyAddress')
  136. // uni.showToast({title:res.msg})
  137. // setTimeout(()=>{
  138. // uni.navigateBack()
  139. // },800)
  140. } else {
  141. this.flag = true;
  142. }
  143. });
  144. },
  145. //去选择地址
  146. selectAddress() {
  147. uni.navigateTo({ url: '/pages/me/address?type=1' });
  148. },
  149. //获取回收信息
  150. getApply() {
  151. this.$api.checkDeliveryInfo({ record_ids: this.id }).then(res => {
  152. if (res.code === 1) {
  153. this.applyList = res.data.order_info;
  154. this.totalPrice = res.data.total_delivery_fee;
  155. }
  156. });
  157. },
  158. //获取默认地址
  159. getAddress() {
  160. this.$api.myAddress({ is_default: 1 }).then(res => {
  161. if (res.code === 1) {
  162. if (res.data.length != 0) {
  163. this.applyAddress = res.data[0];
  164. }
  165. }
  166. });
  167. },
  168. changePay(index) {
  169. this.payIndex = index;
  170. }
  171. },
  172. onShow() {
  173. if (uni.getStorageSync('applyAddress')) {
  174. this.applyAddress = JSON.parse(uni.getStorageSync('applyAddress'));
  175. } else {
  176. this.getAddress();
  177. }
  178. },
  179. onLoad({ id }) {
  180. this.id = id;
  181. this.getApply();
  182. }
  183. };
  184. </script>
  185. <style lang="scss">
  186. .deposit_main_ul {
  187. margin-top: 20rpx;
  188. background: #ffffff;
  189. .deposit_main_li {
  190. padding: 30rpx 20rpx;
  191. .deposit_main_img {
  192. image {
  193. width: 50rpx;
  194. height: 50rpx;
  195. margin-right: 20rpx;
  196. }
  197. text {
  198. font-size: 28rpx;
  199. }
  200. }
  201. .deposit_main_li_select {
  202. width: 32rpx;
  203. height: 32rpx;
  204. }
  205. }
  206. }
  207. .apply {
  208. padding: 0 30rpx;
  209. padding-bottom: 60rpx;
  210. .apply_head_name {
  211. padding: 30rpx 0;
  212. font-size: 28rpx;
  213. font-weight: bold;
  214. }
  215. .apply_head_ipt {
  216. padding: 30rpx;
  217. border-radius: 10rpx;
  218. background: #ffffff;
  219. input {
  220. font-size: 28rpx;
  221. }
  222. image {
  223. width: 22rpx;
  224. height: 22rpx;
  225. }
  226. }
  227. .apply_head_address {
  228. .address_have_li_title {
  229. color: #666666;
  230. font-size: 28rpx;
  231. }
  232. .address_have_li_txt {
  233. font-size: 26rpx;
  234. margin: 20rpx 0;
  235. }
  236. .address_have_li_name {
  237. text {
  238. color: #999999;
  239. font-size: 30rpx;
  240. &:last-child {
  241. font-size: 28rpx;
  242. margin-left: 20rpx;
  243. }
  244. }
  245. }
  246. }
  247. }
  248. .apply_main_name {
  249. font-size: 28rpx;
  250. font-weight: bold;
  251. padding: 30rpx 0 20rpx 0;
  252. }
  253. .apply_main {
  254. padding-bottom: 98rpx;
  255. }
  256. .apply_main_li {
  257. margin-bottom: 20rpx;
  258. &:last-child {
  259. margin-bottom: 0;
  260. }
  261. .apply_main_li_box {
  262. padding: 30rpx;
  263. background: #ffffff;
  264. }
  265. border-radius: 20rpx;
  266. .apply_main_li_img {
  267. width: 168rpx;
  268. height: 168rpx;
  269. image {
  270. border-radius: 10rpx;
  271. }
  272. margin-right: 20rpx;
  273. }
  274. .apply_main_li_main {
  275. height: 168rpx;
  276. align-items: flex-start;
  277. flex-direction: column;
  278. }
  279. .apply_main_li_name {
  280. font-size: 28rpx;
  281. line-height: 36rpx;
  282. }
  283. .apply_main_li_time {
  284. color: #999999;
  285. }
  286. }
  287. .apply_order {
  288. padding: 0 30rpx 0 20rpx;
  289. border-radius: 10rpx;
  290. background: #ffffff;
  291. margin-top: 20rpx;
  292. .apply_order_li {
  293. padding: 30rpx 0;
  294. text {
  295. font-size: 26rpx;
  296. &:last-child {
  297. color: #999999;
  298. }
  299. }
  300. .red {
  301. color: #cf271b !important;
  302. }
  303. }
  304. }
  305. .apply_btn {
  306. color: #333333;
  307. font-size: 30rpx;
  308. font-weight: bold;
  309. height: 98rpx;
  310. margin-top: 212rpx;
  311. background: #ffffff;
  312. box-shadow: 0rpx 0rpx 121rpx 0rpx rgba(63, 52, 2, 0.12);
  313. border-radius: 10rpx;
  314. }
  315. .apply_footer {
  316. width: 100%;
  317. left: 0;
  318. bottom: 0;
  319. height: 98rpx;
  320. position: fixed;
  321. padding-left: 30rpx;
  322. background: #ffffff;
  323. .apply_footer_total {
  324. font-size: 28rpx;
  325. }
  326. .apply_footer_btn {
  327. width: 280rpx;
  328. height: 100%;
  329. color: #ffffff;
  330. font-size: 28rpx;
  331. background: -webkit-linear-gradient(0deg, #89f7fe 0%, #66a6ff 100%);
  332. }
  333. }
  334. </style>