orderListButton.vue 7.9 KB

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