pay.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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. })
  98. },
  99. methods: {
  100. getDetail() {
  101. this.$api
  102. .post('/material/salses/detail', {
  103. salesId: this.orderId
  104. })
  105. .then(res => {
  106. this.detail = res.data
  107. this.loadStatus = 0
  108. })
  109. .catch(res => {
  110. this.errorText = res.message
  111. this.loadStatus = 2
  112. })
  113. .finally(res => {
  114. this.refresherTriggered = false
  115. })
  116. },
  117. // 取消订单
  118. cancelOrder() {
  119. this.$modal({
  120. content: '确认取消订单吗?'
  121. })
  122. .then(() => {
  123. this.$api
  124. .post('/material/salses/cancel', {
  125. salesId: this.orderId
  126. })
  127. .then(res => {
  128. this.$successToast()
  129. this.$navToPage(
  130. {
  131. delta: 1
  132. },
  133. 'navigateBack'
  134. )
  135. })
  136. })
  137. .catch(() => {})
  138. },
  139. // 下单
  140. submitData() {
  141. if (this.payNo) {
  142. mini_env(bool => {
  143. if (bool) {
  144. this.$api
  145. .postJson('/material/salses/save/pay/order', {
  146. salesId: this.orderId,
  147. payConfigId: this.payNo,
  148. miniPay: true,
  149. openId: this.$store.state.user.miniOpenId
  150. })
  151. .then(res => {
  152. uniWebview.navigateTo({
  153. url: `/pages/pay/otherPay?${Object.entries({
  154. appOrderId: res.data.appOrderId,
  155. appid: res.data.appid
  156. })
  157. .map(item => item.join('='))
  158. .join('&')}`
  159. })
  160. })
  161. } else {
  162. // 公众号支付
  163. // weixinPay(res.data, function (res) {
  164. // that.paySuccess()
  165. // })
  166. }
  167. })
  168. } else {
  169. this.$toast(`请选择支付商户`)
  170. }
  171. // if (this.canScanCode > 0) return this.$toast(`请等待${this.canScanCode}秒后重试`)
  172. // mini_env(bool => {
  173. // /material/salses/get/pay/config
  174. // this.$api
  175. // .post('/material/salses/pay', {
  176. // salesId: this.orderId,
  177. // ...(() => {
  178. // if (bool) {
  179. // return {
  180. // miniPay: true,
  181. // openId: this.$store.state.user.miniOpenId
  182. // }
  183. // }
  184. // return {}
  185. // })()
  186. // })
  187. // .then(res => {
  188. // if (!res.data.isPay) {
  189. // this.paySuccess()
  190. // } else {
  191. // if (bool) {
  192. // uniWebview.navigateTo({
  193. // url: `/pages/pay/pay?${Object.entries({
  194. // ...res.data,
  195. // payPackage: res.data.payPackage.split('=')[0] || '',
  196. // payPackageVal: res.data.payPackage.split('=')[1] || ''
  197. // })
  198. // .map(item => item.join('='))
  199. // .join('&')}`
  200. // })
  201. // } else {
  202. // weixinPay(res.data, function (res) {
  203. // that.paySuccess()
  204. // })
  205. // }
  206. // }
  207. // })
  208. // .catch(res => {
  209. // this.$tips(res.message)
  210. // })
  211. // .finally(() => {
  212. // this.canScanCode = 15
  213. // let time = setInterval(() => {
  214. // if (this.canScanCode > 0) {
  215. // this.canScanCode = this.canScanCode - 1
  216. // } else {
  217. // clearInterval(time)
  218. // }
  219. // }, 1000)
  220. // })
  221. // })
  222. },
  223. paySuccess() {
  224. this.$modal({
  225. content: '支付成功',
  226. cancelText: '回到首页',
  227. confirmText: '查看记录'
  228. })
  229. .then(() => {
  230. this.$navToPage(
  231. {
  232. url: `/packageMaterial/pages/stock/buyRecord`
  233. },
  234. 'reLaunch'
  235. )
  236. })
  237. .catch(() => {
  238. this.$navToPage(
  239. {
  240. url: `/pages/index/index`
  241. },
  242. 'switchTab'
  243. )
  244. })
  245. }
  246. }
  247. }
  248. </script>
  249. <style lang="scss" scoped>
  250. .card {
  251. @include zj-card;
  252. }
  253. .materials-container {
  254. padding: 30rpx;
  255. .title {
  256. text-align: center;
  257. margin-top: 30rpx;
  258. .t1 {
  259. font-size: 32rpx;
  260. font-weight: 500;
  261. }
  262. .t2 {
  263. font-size: 40rpx;
  264. color: $minor-color;
  265. margin-top: 20rpx;
  266. text {
  267. font-size: 56rpx;
  268. font-weight: 500;
  269. }
  270. }
  271. }
  272. .id {
  273. margin-top: 50rpx;
  274. text {
  275. color: $sec-font;
  276. }
  277. }
  278. .product {
  279. background: #f5f5f5;
  280. border-radius: 12rpx;
  281. padding: 20rpx;
  282. margin-top: 20rpx;
  283. .it {
  284. display: flex;
  285. align-items: flex-end;
  286. margin-bottom: 20rpx;
  287. .name {
  288. flex: 1;
  289. font-size: 28rpx;
  290. font-weight: 500;
  291. text {
  292. color: $sec-font;
  293. margin-left: 12rpx;
  294. font-weight: normal;
  295. }
  296. }
  297. .price {
  298. margin-left: 30rpx;
  299. font-size: 28rpx;
  300. font-weight: 500;
  301. }
  302. }
  303. .total {
  304. display: flex;
  305. align-items: center;
  306. justify-content: flex-end;
  307. margin-top: 30rpx;
  308. .text {
  309. font-size: 28rpx;
  310. color: $sec-font;
  311. }
  312. .price {
  313. font-size: 28rpx;
  314. color: $minor-color;
  315. font-weight: 500;
  316. }
  317. }
  318. }
  319. .row {
  320. margin-top: 20rpx;
  321. line-height: 40rpx;
  322. display: flex;
  323. font-size: 28rpx;
  324. text {
  325. color: $sec-font;
  326. flex-shrink: 0;
  327. line-height: 40rpx;
  328. }
  329. }
  330. }
  331. .pay-container {
  332. padding: 30rpx;
  333. .top {
  334. margin-bottom: 50rpx;
  335. }
  336. .item {
  337. display: flex;
  338. align-items: center;
  339. justify-content: space-between;
  340. margin: 20rpx 0;
  341. .left {
  342. .iconfont {
  343. font-size: 40rpx;
  344. color: $sec-font;
  345. }
  346. .text {
  347. margin-left: 18rpx;
  348. font-size: 32rpx;
  349. }
  350. .active {
  351. color: $theme-color;
  352. }
  353. }
  354. .right {
  355. .text {
  356. margin-left: 18rpx;
  357. font-size: 32rpx;
  358. }
  359. }
  360. }
  361. }
  362. </style>