pay.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <view>
  3. <Loading :type="3" :loadStatus="loadStatus" :showText="errorText" />
  4. <zj-page-layout :hasFooter="true" v-if="detail">
  5. <view style="padding: 1rpx 30rpx">
  6. <view class="materials-container card mt30">
  7. <view class="title">
  8. <view class="t1">支付金额</view>
  9. <view class="t2"
  10. >¥<text>{{ detail.totalAmount | priceFilter }}</text></view
  11. >
  12. </view>
  13. <view class="id"><text>费用单号:</text>{{ detail.salesId }}</view>
  14. <view class="product">
  15. <view class="it" v-for="(item, index) in detail.items" :key="index">
  16. <view class="name"
  17. >{{ item.goodsName }}<text>×{{ item.salesQty }}{{ item.goodsSalesUnit }}</text></view
  18. >
  19. <view class="price">¥{{ item.saleAmount | priceFilter }}</view>
  20. </view>
  21. <view class="total">
  22. <view class="text">合计:</view>
  23. <view class="price">¥{{ detail.totalAmount | priceFilter }}</view>
  24. </view>
  25. </view>
  26. <view class="row"><text>备注:</text>{{ detail.remark }}</view>
  27. <!-- <view class="row"><text>操作人:</text>模式一</view> -->
  28. </view>
  29. <!-- <view class="pay-container card mt30">
  30. <view class="top">请选择客户支付方式</view>
  31. <view class="item">
  32. <view class="left">
  33. <text class="iconfont icon-weixinzhifu"></text>
  34. <text class="text">微信支付</text>
  35. </view>
  36. <view class="right">
  37. <text class="iconfont icon-danxuan2 active"></text>
  38. </view>
  39. </view>
  40. </view> -->
  41. <view class="pay-container card mt30">
  42. <view class="top">支付信息</view>
  43. <view class="item" v-for="(item, index) in payNoList" :key="index" @click="payNo = item.id">
  44. <view class="left">
  45. <text
  46. :class="{
  47. iconfont: true,
  48. 'icon-danxuan2': true,
  49. active: payNo === item.id
  50. }"
  51. ></text>
  52. </view>
  53. <view class="right">
  54. <text class="text">{{ item.name }}</text>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <template slot="footer">
  60. <view class="footer-btn-group">
  61. <u-button text="取消订单" @click="cancelOrder"></u-button>
  62. <u-button text="确认支付" type="primary" @click="submitData"></u-button>
  63. </view>
  64. </template>
  65. </zj-page-layout>
  66. </view>
  67. </template>
  68. <script>
  69. import { weixinPay, mini_env } from '@/common/utils/util.js'
  70. export default {
  71. data() {
  72. return {
  73. orderId: null,
  74. refresherTriggered: false,
  75. loadStatus: 0,
  76. errorText: '',
  77. detail: null,
  78. canScanCode: 0,
  79. payNoList: [],
  80. payNo: '',
  81. websitId: '',
  82. goodsType: ''
  83. }
  84. },
  85. onLoad({ orderId, websitId, goodsType }) {
  86. this.orderId = orderId
  87. this.websitId = websitId
  88. this.goodsType = goodsType
  89. this.getDetail()
  90. this.$api
  91. .post('/material/salses/get/pay/config', {
  92. goodsType: this.goodsType,
  93. websitId: this.websitId
  94. })
  95. .then(res => {
  96. this.payNoList = res.data
  97. res.data.map(item => {
  98. if (!this.payNo) {
  99. this.payNo = item.id
  100. }
  101. })
  102. })
  103. },
  104. methods: {
  105. getDetail() {
  106. this.$api
  107. .post('/material/salses/detail', {
  108. salesId: this.orderId
  109. })
  110. .then(res => {
  111. this.detail = res.data
  112. this.loadStatus = 0
  113. })
  114. .catch(res => {
  115. this.errorText = res.message
  116. this.loadStatus = 2
  117. })
  118. .finally(res => {
  119. this.refresherTriggered = false
  120. })
  121. },
  122. // 取消订单
  123. cancelOrder() {
  124. this.$modal({
  125. content: '确认取消订单吗?'
  126. })
  127. .then(() => {
  128. this.$api
  129. .post('/material/salses/cancel', {
  130. salesId: this.orderId
  131. })
  132. .then(res => {
  133. this.$successToast()
  134. this.$navToPage(
  135. {
  136. delta: 1
  137. },
  138. 'navigateBack'
  139. )
  140. })
  141. })
  142. .catch(() => {})
  143. },
  144. // 下单
  145. submitData() {
  146. if (this.payNo) {
  147. mini_env(bool => {
  148. if (bool) {
  149. this.$api
  150. .postJson('/material/salses/save/pay/order', {
  151. salesId: this.orderId,
  152. payConfigId: this.payNo,
  153. miniPay: true,
  154. openId: this.$store.state.user.miniOpenId
  155. })
  156. .then(res => {
  157. // uniWebview.navigateTo({
  158. // url: `/pages/pay/otherPay?${Object.entries({
  159. // appOrderId: res.data.id,
  160. // appid: res.data.appid
  161. // })
  162. // .map(item => item.join('='))
  163. // .join('&')}`
  164. // })
  165. })
  166. } else {
  167. this.$api
  168. .get('/material/salses/pay', {
  169. key: this.payNo,
  170. salesId: this.orderId,
  171. payType: 'W02',
  172. openid: ''
  173. })
  174. .then(res => {
  175. // 公众号支付
  176. // weixinPay(JSON.parse(res?.data?.codeUrl || {}), function (res) {
  177. // that.paySuccess()
  178. // })
  179. })
  180. }
  181. })
  182. } else {
  183. this.$toast(`请选择支付商户`)
  184. }
  185. // if (this.canScanCode > 0) return this.$toast(`请等待${this.canScanCode}秒后重试`)
  186. // mini_env(bool => {
  187. // /material/salses/get/pay/config
  188. // this.$api
  189. // .post('/material/salses/pay', {
  190. // salesId: this.orderId,
  191. // ...(() => {
  192. // if (bool) {
  193. // return {
  194. // miniPay: true,
  195. // openId: this.$store.state.user.miniOpenId
  196. // }
  197. // }
  198. // return {}
  199. // })()
  200. // })
  201. // .then(res => {
  202. // if (!res.data.isPay) {
  203. // this.paySuccess()
  204. // } else {
  205. // if (bool) {
  206. // uniWebview.navigateTo({
  207. // url: `/pages/pay/pay?${Object.entries({
  208. // ...res.data,
  209. // payPackage: res.data.payPackage.split('=')[0] || '',
  210. // payPackageVal: res.data.payPackage.split('=')[1] || ''
  211. // })
  212. // .map(item => item.join('='))
  213. // .join('&')}`
  214. // })
  215. // } else {
  216. // weixinPay(res.data, function (res) {
  217. // that.paySuccess()
  218. // })
  219. // }
  220. // }
  221. // })
  222. // .catch(res => {
  223. // this.$tips(res.message)
  224. // })
  225. // .finally(() => {
  226. // this.canScanCode = 15
  227. // let time = setInterval(() => {
  228. // if (this.canScanCode > 0) {
  229. // this.canScanCode = this.canScanCode - 1
  230. // } else {
  231. // clearInterval(time)
  232. // }
  233. // }, 1000)
  234. // })
  235. // })
  236. },
  237. paySuccess() {
  238. this.$modal({
  239. content: '支付成功',
  240. cancelText: '回到首页',
  241. confirmText: '查看记录'
  242. })
  243. .then(() => {
  244. this.$navToPage(
  245. {
  246. url: `/packageMaterial/pages/stock/buyRecord`
  247. },
  248. 'reLaunch'
  249. )
  250. })
  251. .catch(() => {
  252. this.$navToPage(
  253. {
  254. url: `/pages/index/index`
  255. },
  256. 'switchTab'
  257. )
  258. })
  259. }
  260. }
  261. }
  262. </script>
  263. <style lang="scss" scoped>
  264. .card {
  265. @include zj-card;
  266. }
  267. .materials-container {
  268. padding: 30rpx;
  269. .title {
  270. text-align: center;
  271. margin-top: 30rpx;
  272. .t1 {
  273. font-size: 32rpx;
  274. font-weight: 500;
  275. }
  276. .t2 {
  277. font-size: 40rpx;
  278. color: $minor-color;
  279. margin-top: 20rpx;
  280. text {
  281. font-size: 56rpx;
  282. font-weight: 500;
  283. }
  284. }
  285. }
  286. .id {
  287. margin-top: 50rpx;
  288. text {
  289. color: $sec-font;
  290. }
  291. }
  292. .product {
  293. background: #f5f5f5;
  294. border-radius: 12rpx;
  295. padding: 20rpx;
  296. margin-top: 20rpx;
  297. .it {
  298. display: flex;
  299. align-items: flex-end;
  300. margin-bottom: 20rpx;
  301. .name {
  302. flex: 1;
  303. font-size: 28rpx;
  304. font-weight: 500;
  305. text {
  306. color: $sec-font;
  307. margin-left: 12rpx;
  308. font-weight: normal;
  309. }
  310. }
  311. .price {
  312. margin-left: 30rpx;
  313. font-size: 28rpx;
  314. font-weight: 500;
  315. }
  316. }
  317. .total {
  318. display: flex;
  319. align-items: center;
  320. justify-content: flex-end;
  321. margin-top: 30rpx;
  322. .text {
  323. font-size: 28rpx;
  324. color: $sec-font;
  325. }
  326. .price {
  327. font-size: 28rpx;
  328. color: $minor-color;
  329. font-weight: 500;
  330. }
  331. }
  332. }
  333. .row {
  334. margin-top: 20rpx;
  335. line-height: 40rpx;
  336. display: flex;
  337. font-size: 28rpx;
  338. text {
  339. color: $sec-font;
  340. flex-shrink: 0;
  341. line-height: 40rpx;
  342. }
  343. }
  344. }
  345. .pay-container {
  346. padding: 30rpx;
  347. .top {
  348. margin-bottom: 50rpx;
  349. }
  350. .item {
  351. display: flex;
  352. align-items: center;
  353. justify-content: space-between;
  354. margin: 20rpx 0;
  355. .left {
  356. .iconfont {
  357. font-size: 40rpx;
  358. color: $sec-font;
  359. }
  360. .text {
  361. margin-left: 18rpx;
  362. font-size: 32rpx;
  363. }
  364. .active {
  365. color: $theme-color;
  366. }
  367. }
  368. .right {
  369. .text {
  370. margin-left: 18rpx;
  371. font-size: 32rpx;
  372. }
  373. }
  374. }
  375. }
  376. </style>