cm-list-button.vue 7.9 KB

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