cm-details-button.vue 8.8 KB

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