cm-list-button.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template name="button">
  2. <view class="button-template">
  3. <!-- 底部按钮 -->
  4. <view class="button-content">
  5. <view class="btn btn-cancel" v-if="btnState.isCancel" @click.stop="btnConfirm('cancel', shopOrderId)">取消订单
  6. </view>
  7. <view class="btn btn-cancel" v-if="secondHandOrderFlag != 1 && !rechargeGoods"
  8. @click.stop="btnConfirm('again', shopOrderId)">再来一单</view>
  9. <!-- <view class="btn btn-cancel" v-if="btnState.isDelete" @click.stop="btnConfirm('delete',orderId)">删除订单</view> -->
  10. <template>
  11. <view class="btn btn-cancel" v-if="btnState.isPay && order.onlinePay === 1" @click.stop="onSharePay(shopOrderId, userId)">
  12. 分享支付</view>
  13. <view class="btn btn-cancel" v-else @click.stop="onShareCode(shopOrderId, userId, 2)">分享订单</view>
  14. </template>
  15. <view class="btn btn-query" v-if="btnState.isQuery && order.secondHandOrderFlag != 1"
  16. @click.stop="btnConfirm('query', shopOrderId)">查看物流</view>
  17. <!-- <view class="btn btn-color" v-if="btnState.isConfirm" @click.stop="btnConfirm('confirm', shopOrderId)"
  18. >确认订单</view
  19. > -->
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import orderBtnMixins from '../mixins/orderBtnMixins.js'
  25. export default {
  26. mixins: [orderBtnMixins],
  27. name: 'button',
  28. props: {
  29. status: {
  30. type: Number
  31. },
  32. order: {
  33. type: Object
  34. },
  35. shopOrderId: {
  36. type: Number
  37. },
  38. userId: {
  39. type: Number
  40. },
  41. rechargeGoods: {
  42. type: Boolean
  43. },
  44. serviceProviderId: {
  45. type: Number
  46. },
  47. secondHandOrderFlag: {
  48. type: String
  49. }
  50. },
  51. data() {
  52. return {
  53. isShare: true,
  54. shareCode: '',
  55. btnState: this.initStatus(),
  56. mapStateArr: [
  57. { label: 'isQuery', val: [2, 3, 5, 6, 12, 13, 22, 23, 32, 33], status: true },
  58. { label: 'isDelete', val: [4], status: true },
  59. { label: 'isCancel', val: [0, 11], status: true },
  60. { label: 'isConfirm', val: [0], status: true },
  61. { label: 'isPay', val: [11, 12, 13, 21, 22, 23], status: true }
  62. ]
  63. }
  64. },
  65. created() {
  66. this.initData(this.status)
  67. },
  68. computed: {},
  69. watch: {
  70. status: {
  71. handler: function(val) {
  72. this.initData(val)
  73. },
  74. deep: true //对象内部的属性监听,也叫深度监听
  75. }
  76. },
  77. methods: {
  78. initData(resVal) {
  79. /**
  80. * @分享按钮统一显示
  81. * @按钮根据状态显示
  82. * @(4、5、7、12、22、23、32)显示[查看物流]按钮,其他隐藏
  83. * @(6)显示[删除订单],其他隐藏
  84. * @(0、111)显示[取消订单],其他隐藏
  85. * @(21,31)只显示分享
  86. * @(13,33)显示[确认收货]和[查看物流]
  87. */
  88. this.btnState = this.initStatus()
  89. this.mapStateArr.forEach(el => {
  90. el.val.forEach(value => {
  91. if (resVal === value) {
  92. this.btnState[el.label] = el.status
  93. }
  94. })
  95. })
  96. },
  97. initStatus() {
  98. let btnState = {
  99. isDelete: false,
  100. isCancel: false,
  101. isConfirm: false,
  102. isShare: true
  103. }
  104. return btnState
  105. },
  106. getShareCode(code) {
  107. this.shareCode = code
  108. },
  109. // 分享支付
  110. onSharePay(shopOrderId) {
  111. this.getPayOrderInfo(shopOrderId)
  112. },
  113. onShareCode(shopOrderId, userId, type) {
  114. if (this.order.onlinePay === 2) {
  115. this.$util.modal(
  116. '提示',
  117. '本订单不能进行线上支付,请让客户选择线下转账方式付款',
  118. '继续分享',
  119. '知道了',
  120. true,
  121. () => {
  122. this.$parent.isShareModal = true
  123. this.$parent.handleShopOrderId = shopOrderId
  124. this.$parent.btnClubUserId = userId
  125. this.$parent.isShareType = type
  126. this.$emit('shareConfirm')
  127. }
  128. )
  129. } else {
  130. this.$parent.isShareModal = true
  131. this.$parent.handleShopOrderId = shopOrderId
  132. this.$parent.btnClubUserId = userId
  133. this.$parent.isShareType = type
  134. this.$emit('shareConfirm')
  135. }
  136. },
  137. btnConfirm(type, shopOrderId) {
  138. let data = {
  139. type: type,
  140. shopOrderId: shopOrderId
  141. }
  142. this.$emit('buttonConfirm', data)
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss">
  148. .button-template {
  149. width: 100%;
  150. height: auto;
  151. float: left;
  152. background: #ffffff;
  153. .button-content {
  154. height: auto;
  155. float: right;
  156. position: relative;
  157. margin: 20rpx 0;
  158. .share-code {
  159. width: 200rpx;
  160. height: 64rpx;
  161. line-height: 64rpx;
  162. color: #2a45ff;
  163. text-align: left;
  164. position: absolute;
  165. font-size: $font-size-28;
  166. font-weight: bold;
  167. left: 24rpx;
  168. top: 24rpx;
  169. }
  170. .btn {
  171. width: 160rpx;
  172. height: 64rpx;
  173. line-height: 64rpx;
  174. font-size: $font-size-26;
  175. color: #ffffff;
  176. text-align: center;
  177. border-radius: 34rpx;
  178. // float: right;
  179. display: inline-block;
  180. }
  181. .btn-color {
  182. background: $btn-confirm;
  183. // margin: 22rpx 0 22rpx 22rpx;
  184. }
  185. .btn-cancel {
  186. border: 2rpx solid #999999;
  187. background: #ffffff;
  188. color: #666666;
  189. // float: left;
  190. margin-left: 10rpx;
  191. }
  192. .btn-delete {
  193. background: linear-gradient(315deg, rgba(255, 163, 3, 1) 0%, rgba(255, 53, 1, 1) 100%);
  194. }
  195. .btn-query {
  196. background: linear-gradient(135deg, rgba(255, 212, 129, 1) 0%, rgba(198, 129, 0, 1) 100%);
  197. }
  198. .btn-confirm {
  199. background: linear-gradient(315deg, rgba(231, 0, 0, 1) 0%, rgba(255, 104, 1, 1) 100%);
  200. }
  201. .btn-share {
  202. background: linear-gradient(315deg, rgba(0, 212, 150, 1) 0%, rgba(126, 243, 174, 1) 100%);
  203. margin-right: 0;
  204. position: relative;
  205. .tips {
  206. width: 160rpx;
  207. height: 34rpx;
  208. padding: 10rpx 10rpx;
  209. background: #ff5b00;
  210. border-radius: 8rpx;
  211. position: absolute;
  212. color: #ffffff;
  213. line-height: 34rpx;
  214. font-size: $font-size-24;
  215. text-align: left;
  216. right: 0;
  217. top: -65rpx;
  218. &:before {
  219. content: '';
  220. width: 25rpx;
  221. height: 25rpx;
  222. background: #ff5b00;
  223. position: absolute;
  224. bottom: -8rpx;
  225. left: 30rpx;
  226. z-index: -1;
  227. transform: rotate(45deg);
  228. }
  229. }
  230. }
  231. }
  232. }
  233. </style>