applyFaHuo.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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">
  24. <image :src="item.goods_image" mode="aspectFill"></image>
  25. </view>
  26. <view class="apply_main_li_main flex">
  27. <view class="apply_main_li_name">{{ item.goods_name }}</view>
  28. <view class="apply_main_li_time">开箱日期:{{ item.time }}</view>
  29. </view>
  30. </view>
  31. <view class="apply_order">
  32. <view class="apply_order_li flex">
  33. <text>付款金额</text>
  34. <text class="red">{{ item.pay_amount }}</text>
  35. </view>
  36. <view class="apply_order_li flex">
  37. <text>支付方式</text>
  38. <text>{{ item.pay_method }}</text>
  39. </view>
  40. <view class="apply_order_li flex">
  41. <text>运费</text>
  42. <text>{{ item.delivery_fee }}</text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="deposit_main_ul">
  48. <view class="deposit_main_li flex" v-for="(item,index) in payList" :key="index" @click="changePay(item.type)">
  49. <view class="deposit_main_img flexs">
  50. <image :src="item.image" mode=""></image>
  51. <text>{{ item.name }}{{ item.account ? '('+ item.account +')' : '' }}</text>
  52. </view>
  53. <view class="deposit_main_li_select">
  54. <image :src="item.type == payIndex ? '/static/image/publice/xuanzhong1@2x.png' : '/static/image/publice/weixuanzhong@2x.png'" mode=""></image>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="apply_footer flex">
  60. <view class="apply_footer_total">合计:¥{{ totalPrice }}</view>
  61. <view class="apply_footer_btn center" @click="applySubmit">申请发货</view>
  62. </view>
  63. <!-- <button class="apply_btn" hover-class="hover-view" @click="applySubmit">申请发货</button> -->
  64. </view>
  65. </template>
  66. <script>
  67. export default {
  68. data() {
  69. return {
  70. id:'',//回收ID
  71. flag:true,//
  72. totalPrice:'',
  73. applyList:[],//回收列表
  74. applyAddress:{},//收货地址
  75. payIndex:1,//支付方式
  76. payList:[
  77. // {
  78. // name:'微信支付',
  79. // type:'0',
  80. // account:'',
  81. // image:'/static/image/me/weixin@2x.png'
  82. // },
  83. {
  84. name:'支付宝支付',
  85. type:'1',
  86. account:'',
  87. image:'/static/image/me/zhifubao@2x.png'
  88. }
  89. ],//支付列表
  90. };
  91. },
  92. methods:{
  93. //申请发货
  94. applySubmit () {
  95. if (!this.applyAddress.address_id) return uni.showToast({title:'请选择地址',icon:'none'})
  96. let ids = []
  97. this.applyList.forEach(item=>{
  98. ids.push(item.record_id)
  99. })
  100. if (!this.flag) return
  101. this.flag = false
  102. this.$api.applyDelivery({record_ids:ids.join(','),address_id:this.applyAddress.address_id}).then(res=>{
  103. if (res.code === 1) {
  104. if(res.data.delivery_fee > 0){
  105. if (this.payIndex == 2) {
  106. this.$http.post(res.data.wechat).then(res=>{
  107. if (res.code === 1) {
  108. WeixinJSBridge.invoke('getBrandWCPayRequest', {
  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. } else if (res.code === 403) {
  125. }
  126. })
  127. } else {
  128. location.href = res.data[this.payIndex == 0 ? 'wechat' : 'alipay'] + '?token=' + uni.getStorageSync('token')
  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>