cm-list-button.vue 6.0 KB

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