cm-details-button.vue 5.6 KB

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