cm-list-button.vue 5.3 KB

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