cashier.vue 5.9 KB

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