cashier.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view style="overflow: hidden;">
  3. <payment-pasword ref="paymentPassword" mode="1" @submit="balancePay"></payment-pasword>
  4. <timer-tips v-if="orders.length" :createtime="orders[0].createtime"></timer-tips>
  5. <view class="order-list">
  6. <view v-for="(order,index) in orders" :key="index" class="order-item">
  7. <view class="order-head">
  8. <view class="factory-name">{{order.seller.nickname?order.seller.nickname:'省心直供(该厂家暂未设置昵称)'}}</view>
  9. </view>
  10. <view class="order-info" @tap="openDetails(order.id)">
  11. <view class="product-item" v-for="product in order.products_json">
  12. <view class="product-image">
  13. <image class="image" :src="product.spec_image|imagesFilter" mode="scaleToFill"></image>
  14. </view>
  15. <view class="product-info">
  16. <view class="row">
  17. <view class="name">{{product.name}}</view>
  18. <view class="price">¥{{product.spec_price|priceFilter}}</view>
  19. </view>
  20. <view class="row">
  21. <view class="spec">{{product.spec_name}}</view>
  22. <view class="num">×{{product.num}}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="total-price">
  28. 总价 <text class="warning">¥{{order.total_amount}}</text>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="sum">合计:{{total_amount_sum|priceFilter}}元</view>
  33. <view class="pay-method">
  34. <view class="label">请选择支付方式</view>
  35. <view>
  36. <view class="item" :class="{'active':pay_method==='alipay'}"
  37. @tap="pay_method='alipay',pay_provider='alipay'">
  38. <image class="image" src="../../static/alipay.png" mode="scaleToFill"
  39. style="width: 50upx;height: 50upx;"></image>支付宝
  40. </view>
  41. <view class="item" :class="{'active':pay_method==='wechat'}"
  42. @tap="pay_method='wechat',pay_provider='wxpay'">
  43. <image class="image" src="../../static/wxpay.png" mode="scaleToFill"
  44. style="width: 50upx;height: 50upx;"></image>微信支付
  45. </view>
  46. <view class="item" :class="{'active':pay_method==='balance'}" @tap="pay_method='balance'">
  47. <image class="image" src="../../static/logo.png" mode="scaleToFill"
  48. style="width: 50upx;height: 50upx;"></image>使用余额({{$store.state.user.money}})
  49. </view>
  50. </view>
  51. <view class="" style="margin-top: 40upx;">
  52. <button class="pay-btn" type="default" @tap="pay">立即支付</button>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import paymentPasword from "@/components/sanshui-payment-password/index.vue"
  59. export default {
  60. data() {
  61. return {
  62. pay_method: "alipay",
  63. pay_provider: "alipay",
  64. orders: [],
  65. order_no: ""
  66. }
  67. },
  68. components: {
  69. paymentPasword
  70. },
  71. computed: {
  72. total_amount_sum() {
  73. return this.orders.reduce((prev, cur) => {
  74. return prev + Number(cur.total_amount)
  75. }, 0)
  76. }
  77. },
  78. onLoad(option) {
  79. this.order_no = option.order_no,
  80. this.getCashierData();
  81. },
  82. methods: {
  83. getCashierData() {
  84. this.$http.get({
  85. url: "/order/cashier",
  86. data: {
  87. order_no: this.order_no
  88. },
  89. success: (res) => {
  90. this.orders = res.data.data.map((value) => {
  91. value.products_json = JSON.parse(value.products_snapshot)
  92. return value;
  93. })
  94. }
  95. })
  96. },
  97. balancePay(e) {
  98. console.log(e)
  99. this.$http.post({
  100. url: '/order/balancePay',
  101. data: {
  102. 'order_no': this.order_no,
  103. 'pay_method': this.pay_method,
  104. 'amount': this.total_amount_sum,
  105. 'safe_pass': e.value
  106. },
  107. success: (res) => {
  108. uni.navigateTo({
  109. url: "/pages/order/order",
  110. })
  111. }
  112. })
  113. },
  114. pay() {
  115. if (this.pay_method !== 'balance') {
  116. this.$http.get({
  117. url: '/order/pay',
  118. data: {
  119. 'order_no': this.order_no,
  120. 'pay_method': this.pay_method,
  121. 'amount': this.total_amount_sum
  122. },
  123. success: (res) => {
  124. uni.requestPayment({
  125. provider: this.pay_provider,
  126. orderInfo: res.data.data,
  127. success: (res) => {
  128. uni.showModal({
  129. content: JSON.stringify(res)
  130. })
  131. },
  132. fail: (res) => {
  133. uni.showModal({
  134. content: "支付失败",
  135. })
  136. }
  137. })
  138. }
  139. })
  140. } else {
  141. this.$refs.paymentPassword.modalFun('show');
  142. }
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .order {
  149. overflow: hidden;
  150. }
  151. .order-list {
  152. .order-item {
  153. background: white;
  154. margin: 20upx;
  155. padding: 20upx;
  156. border-radius: 20upx;
  157. .order-head {
  158. display: flex;
  159. justify-content: space-between;
  160. margin-bottom: 20upx;
  161. .order-status {
  162. color: $primary-color;
  163. font-size: 24upx;
  164. }
  165. }
  166. .factory-name {
  167. font-size: 28upx;
  168. font-weight: bold;
  169. }
  170. .product-item {
  171. display: flex;
  172. .product-image {
  173. width: 120upx;
  174. height: 120upx;
  175. margin-right: 20upx;
  176. margin-top: 10upx;
  177. .image {
  178. width: 120upx;
  179. height: 120upx;
  180. }
  181. }
  182. .product-info {
  183. flex-grow: 1;
  184. font-size: 28upx;
  185. .name {
  186. font-size: 28upx;
  187. white-space: normal;
  188. display: -webkit-box;
  189. -webkit-box-orient: vertical;
  190. -webkit-line-clamp: 2;
  191. overflow: hidden;
  192. }
  193. .num {
  194. color: #999999;
  195. }
  196. .spec {
  197. font-size: 26upx;
  198. background: #CCCCCC;
  199. color: white;
  200. padding: 0 10upx;
  201. border-radius: 10upx;
  202. }
  203. }
  204. .row {
  205. display: flex;
  206. justify-content: space-between;
  207. margin-bottom: 10upx;
  208. }
  209. }
  210. .total-price {
  211. text-align: right;
  212. font-size: 28upx;
  213. padding: 10upx 0;
  214. .warning {
  215. color: $primary-color;
  216. font-weight: bold;
  217. }
  218. }
  219. }
  220. }
  221. .sum {
  222. margin: 20upx;
  223. font-size: 30upx;
  224. text-align: right;
  225. font-weight: bold;
  226. }
  227. .pay-method {
  228. margin: 20upx;
  229. padding: 20upx;
  230. background: white;
  231. .label {
  232. font-size: 30upx;
  233. margin-bottom: 20upx;
  234. }
  235. .item {
  236. height: 80upx;
  237. display: flex;
  238. align-items: center;
  239. font-size: 30upx;
  240. border-bottom: 2upx solid #F5F5F5;
  241. .image {
  242. margin-right: 10upx;
  243. }
  244. &.active {
  245. background: url(../../static/gou.png) no-repeat;
  246. background-size: 40upx 40upx;
  247. background-position: 600upx 20upx;
  248. }
  249. }
  250. }
  251. .pay-btn {
  252. margin: 20upx 0;
  253. background: $primary-color;
  254. color: white;
  255. font-size: 32upx;
  256. font-weight: bold;
  257. }
  258. </style>