index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <view>
  3. <view v-show="showData" class="container">
  4. <view style="padding: 20rpx 48rpx">
  5. <img src="../../static/img/logo.png" class="logImg" alt="">
  6. <view v-if="form.status" class="container_title">
  7. <image src="../../static/img/w7.png" mode="widthFix" style="width: 100rpx; margin-right: 10rpx"></image>
  8. <text>已完成支付</text>
  9. </view>
  10. </view>
  11. <view class="boxList">
  12. <view v-for="(item, i) in list" :key="i">
  13. <view v-show="i != 0 && list.length > 1" class="image">
  14. <image src="../../static/img/line.png" style="width: 100%;" mode="widthFix" alt="">
  15. </view>
  16. <view class="box nav" :class="getStyle(i, list.length)">
  17. <view class="box_item">
  18. <text class="textL">退货人:</text>
  19. <text class="textR">{{ item.customer_name }}</text>
  20. </view>
  21. <view class="box_item">
  22. <text class="textL">手机号:</text>
  23. <text class="textR">{{ item.customer_phone | hideMiddle }}</text>
  24. </view>
  25. <view class="box_line" />
  26. <view class="box_item">
  27. <text class="textL">所属公司客户:</text>
  28. <text class="textR">{{ item.user && item.user.nickname }}</text>
  29. </view>
  30. <view class="box_item">
  31. <text class="textL">手机号:</text>
  32. <text class="textR">{{ item.user && item.user.mobile | hideMiddle }}</text>
  33. </view>
  34. <view class="box_line" />
  35. <view class="box_item" v-for="(v) in item.applydetail">
  36. <text class="textL">{{ v.good_name }}:</text>
  37. <text class="textR">{{ `${v.total + v.unit}` }}</text>
  38. </view>
  39. <view class="box_line" />
  40. <view class="box_item">
  41. <text class="textL">应退差价:</text>
  42. <text class="textR">{{ item.return_price }}</text>
  43. </view>
  44. <view class="box_item">
  45. <text class="textL">实退差价:</text>
  46. <text class="textR">{{ item.fact_money }}</text>
  47. </view>
  48. <view v-show="item.remark" class="box_item">
  49. <text class="textL">备注:</text>
  50. <text class="textR">{{ item.remark }}</text>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="bottom">
  55. <view class="text">
  56. 差价总金额:
  57. </view>
  58. <view class="num">
  59. ¥{{ form.account }}
  60. </view>
  61. <view v-if="!form.status" class="pay" @click="toPay()">
  62. 立即支付
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <view v-show="!showData && finish" class="finish">
  68. <image src="../../static/img/w3.png" mode="widthFix"></image>
  69. <text>{{ message }}</text>
  70. </view>
  71. <view v-show="!showData && !finish" class="notData">
  72. <image src="../../static/img/no_record.png" mode="widthFix"></image>
  73. <!-- <text>暂无数据</text> -->
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. import { getRefundInfo, CustomerReturnPay, getOpenid } from '../../api/index.js';
  79. export default {
  80. data() {
  81. return {
  82. showData: false,
  83. form: {},
  84. list: [],
  85. data: {},
  86. finish: false,
  87. message: '',
  88. openid: ''
  89. }
  90. },
  91. filters: {
  92. hideMiddle(val){ //隐藏号码
  93. if (val === null || !val) {
  94. return '';
  95. } else {
  96. return `${val.substring(0, 3)}****${val.substring(val.length - 4)}`;
  97. }
  98. }
  99. },
  100. onLoad(option) {
  101. let wxcode = this.getUrlParam('code')
  102. if (!wxcode) {
  103. const redirect_uri = 'http://api.app.cliu.cc'
  104. const wxURL = 'https://open.weixin.qq.com/connect/oauth2/authorize'
  105. const appid = 'wx5224793b7dc7f7b7'
  106. let uri = encodeURIComponent(
  107. `${redirect_uri}/h5/#/pages/returnedInfo/index?id=${option.id}&verify=${option.verify}`
  108. );
  109. let authURL =
  110. `${wxURL}?appid=${appid}&redirect_uri=${uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`;
  111. window.location.href = authURL;
  112. return false;
  113. }
  114. getOpenid({
  115. code: wxcode
  116. }).then(res => {
  117. if (res.code == 200) {
  118. this.openid = res.data.openid
  119. } else {
  120. uni.showToast({
  121. title: res.msg || '获取openid失败',
  122. icon: 'none'
  123. })
  124. }
  125. }).catch(err => {
  126. uni.showToast({
  127. title: err || '获取openid失败',
  128. icon: 'none'
  129. })
  130. })
  131. this.data = option
  132. this.getList()
  133. },
  134. methods: {
  135. getStyle(i, l) {
  136. const a = i + 1
  137. if (a == 1 && l == 1) {
  138. return 'nav1'
  139. } else if (a == 1 && l > 1) {
  140. return 'nav3'
  141. } else if (a == l && a != 1) {
  142. return 'nav2'
  143. }
  144. },
  145. //获取code值方法
  146. getUrlParam(name) {
  147. console.log(window.location, 'location');
  148. console.log(window.location.href, 'href');
  149. var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); //构造一个含有目标参数的正则表达式对象
  150. var r = window.location.search.substr(1).match(reg); //匹配目标参数
  151. if (r != null) return decodeURIComponent(r[2]);
  152. // return null; //返回参数值
  153. return ''; //返回参数值
  154. },
  155. getList() {
  156. getRefundInfo({ refund_id: this.data.id, verify: this.data.verify }).then(res => {
  157. if (res.code == 200) {
  158. if (res.data) {
  159. this.showData = true
  160. this.list = res.data.customer_return
  161. this.form = res.data
  162. }
  163. } else if (res.code == 450001) {
  164. this.finish = true
  165. this.message = res.message
  166. } else {
  167. uni.showModal({
  168. content: res.message || '获取失败',
  169. showCancel: false
  170. })
  171. }
  172. }).catch(err => {
  173. })
  174. },
  175. toPay() {
  176. CustomerReturnPay({ refund_id: this.data.id, amount: this.form.account, openid: this.openid }).then(res => {
  177. if (res.code === 200) {
  178. let callback_succ_func = res => {
  179. uni.showToast({
  180. title: '支付成功'
  181. })
  182. }
  183. let callback_error_func = res => {
  184. uni.showModal({
  185. content: '支付失败!',
  186. showCancel: false
  187. })
  188. }
  189. this.wxJsPay(res.data, callback_succ_func, callback_error_func)
  190. } else {
  191. uni.showToast({
  192. title: res.message || '失败',
  193. icon: 'none'
  194. })
  195. return false;
  196. }
  197. })
  198. .catch(err => {})
  199. .finally(() => {
  200. setTimeout(() => {}, 3000)
  201. })
  202. },
  203. //WeixinJSBridge判断
  204. wxJsPay(data, callback_succ_func, callback_error_func) {
  205. if (typeof WeixinJSBridge == 'undefined') {
  206. if (document.addEventListener) {
  207. document.addEventListener('WeixinJSBridgeReady', this.jsApiCall, false);
  208. } else if (document.attachEvent) {
  209. document.attachEvent('WeixinJSBridgeReady', this.jsApiCall);
  210. document.attachEvent('onWeixinJSBridgeReady', this.jsApiCall);
  211. }
  212. } else {
  213. this.jsApiCall(data, callback_succ_func, callback_error_func);
  214. }
  215. },
  216. //调起支付
  217. jsApiCall(data, callback_succ_func, callback_error_func) {
  218. //使用原生的,避免初始化appid问题
  219. WeixinJSBridge.invoke(
  220. 'getBrandWCPayRequest', {
  221. appId: data.appId,
  222. timeStamp: data.timestamp,
  223. nonceStr: data.nonceStr,
  224. package: data.package,
  225. signType: data.signType,
  226. paySign: data.paySign
  227. },
  228. function(res) {
  229. var msg = res.err_msg ? res.err_msg : res.errMsg;
  230. switch (msg) {
  231. // //支付成功时
  232. case 'get_brand_wcpay_request:ok':
  233. // if (callback_succ_func) {
  234. uni.showModal({
  235. title: '支付成功',
  236. showCancel: false,
  237. success: function(res) {
  238. uni.reLaunch({
  239. url: "/pages/payment/payment"
  240. })
  241. },
  242. // complete: function() {
  243. // that.SearchStatus()
  244. // }
  245. });
  246. // }
  247. break;
  248. default:
  249. //支付失败时
  250. WeixinJSBridge.log('支付失败!' + msg + ',请返回重试.');
  251. if (callback_error_func) {
  252. callback_error_func({
  253. msg: msg
  254. });
  255. }
  256. break;
  257. }
  258. }
  259. );
  260. },
  261. }
  262. }
  263. </script>
  264. <style lang="scss" scoped>
  265. page {
  266. background-size: 100% auto;
  267. background-repeat: repeat-y;
  268. background-image: url("../../static/img/wall-min.png");
  269. }
  270. .finish {
  271. display: flex;
  272. justify-content: center;
  273. flex-direction: column;
  274. align-items: center;
  275. color: #fff;
  276. padding-top: 50%;
  277. image {
  278. width: 100rpx;
  279. margin-bottom: 20rpx;
  280. }
  281. }
  282. .notData {
  283. display: flex;
  284. justify-content: center;
  285. flex-direction: column;
  286. align-items: center;
  287. background-color: #fff;
  288. color: #fff;
  289. height: 100vh;
  290. image {
  291. width: 500rpx;
  292. }
  293. }
  294. .container {
  295. width: 100vw;
  296. height: 100%;
  297. padding-top: 40rpx !important;
  298. padding-bottom: 140rpx;
  299. &_title {
  300. display:flex;
  301. color: #fff;
  302. align-items: center;
  303. justify-content: center;
  304. text {
  305. font-size: 40rpx;
  306. font-weight: bold;
  307. }
  308. }
  309. .logImg {
  310. width: 100%;
  311. display: block;
  312. }
  313. .nav1 {
  314. border-radius: 16rpx;
  315. }
  316. .nav2 {
  317. border-radius: 0 0 16rpx 16rpx !important;
  318. }
  319. .nav3 {
  320. border-radius: 16rpx 16rpx 0 0 !important;
  321. }
  322. .boxList {
  323. padding: 0 24rpx;
  324. }
  325. .box {
  326. margin-top: -1rpx;
  327. padding: 24rpx 24rpx 0 24rpx;
  328. background: #FFFFFF;
  329. // border-radius: 16rpx;
  330. &_item {
  331. display: flex;
  332. justify-content: space-between;
  333. text {
  334. font-size: 32rpx;
  335. margin-bottom: 24rpx;
  336. display: block;
  337. }
  338. .textL {
  339. color: #999999;
  340. }
  341. .textR {
  342. color: #333333;
  343. width: 360rpx;
  344. text-align: end;
  345. word-break: break-all;
  346. }
  347. }
  348. &_line {
  349. border-bottom: 2rpx solid #EEEEEE;
  350. margin-bottom: 24rpx;
  351. }
  352. }
  353. .image {
  354. box-sizing: border-box;
  355. display: flex;
  356. flex-direction: column;
  357. }
  358. .bottom {
  359. position: fixed;
  360. height: 112rpx;
  361. left: 0;
  362. bottom: 0;
  363. width: 100%;
  364. border-top: 2rpx solid #EEEEEE;
  365. background-color: #fff;
  366. display: flex;
  367. justify-content: flex-end;
  368. align-items: center;
  369. .pay {
  370. width: 30%;
  371. line-height: 80rpx;
  372. text-align: center;
  373. margin-right: 20rpx;
  374. background: linear-gradient(91deg, #F30000 0%, #FE4815 100%);
  375. border-radius: 44rpx 44rpx 44rpx 44rpx;
  376. font-size: 32rpx;
  377. font-weight: bold;
  378. color: #FFFFFF;
  379. }
  380. .text {
  381. font-size: 26rpx;
  382. color: #333333;
  383. }
  384. .num {
  385. font-size: 34rpx;
  386. color: #FB231F;
  387. font-weight: bold;
  388. margin-right: 20rpx;
  389. }
  390. }
  391. // .bottom {
  392. // position: fixed;
  393. // left: 0;
  394. // bottom: 0;
  395. // width: 100%;
  396. // background-size: 100% auto;
  397. // background-repeat: repeat-y;
  398. // background-image: url("../../static/img/wall-min.png");
  399. // .btn {
  400. // padding: 20rpx 24rpx;
  401. // background-color: #fff;
  402. // display: flex;
  403. // justify-content: center;
  404. // align-items: center;
  405. // .pay {
  406. // width: 100%;
  407. // line-height: 88rpx;
  408. // text-align: center;
  409. // background: linear-gradient(91deg, #F30000 0%, #FE4815 100%);
  410. // border-radius: 44rpx 44rpx 44rpx 44rpx;
  411. // font-size: 32rpx;
  412. // font-weight: bold;
  413. // color: #FFFFFF;
  414. // }
  415. // }
  416. // .totalMoney {
  417. // padding: 86rpx 0 82rpx 0;
  418. // margin: 24rpx 24rpx 40rpx 24rpx;
  419. // border-radius: 16rpx 16rpx 16rpx 16rpx;
  420. // background-color: #fff;
  421. // display: flex;
  422. // flex-direction: column;
  423. // align-items: center;
  424. // font-weight: bold;
  425. // &_text {
  426. // font-size: 36rpx;
  427. // margin-bottom: 24rpx;
  428. // color: #333333;
  429. // }
  430. // &_num {
  431. // font-size: 76rpx;
  432. // color: #FB231F;
  433. // }
  434. // }
  435. // }
  436. }
  437. </style>