app-buttom-button.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <view class="bd-bottom dir-left-nowrap cross-center">
  3. <view class="bd-back dir-top-nowrap main-center cross-center" @click="router">
  4. <image class="bd-icon" src="../../../static/image/icon/index.png"></image>
  5. <text class="bd-text">首页</text>
  6. </view>
  7. <bd-service :name="name" :url="url"></bd-service>
  8. <view v-if="item.goods_stock > 0 && start_time" class="box-grow-1 dir-left-nowrap">
  9. <view v-if="is_alone_buy === 1" @click.stop="turnOn(false)" class="bd-btn but dir-top-nowrap box-grow-1" :class="[is_alone_buy === 1 ? 'bd-btn-left' : '']" :style="{'background': item.buy_goods_auth ? theme.background_s_gradient_btn : '#999999','color': item.buy_goods_auth ? theme.secondary_text : ''}">
  10. <text class="price">
  11. {{singlePrice}}
  12. </text>
  13. <text class="app-text">单独购买</text>
  14. </view>
  15. <view class="bd-btn but dir-top-nowrap box-grow-1" :style="{'background': item.buy_goods_auth ? theme.background_gradient_btn : '#999999','color': theme.main_text}" :class="[is_alone_buy === 1 ? 'bd-btn-right' : '']" @click="turnOn(true)">
  16. <text class="price">{{group_price}}</text>
  17. <text class="app-text">{{groups[set_group_num].groups.people_num}}人拼团</text>
  18. </view>
  19. </view>
  20. <view v-else class="bd-btn bd-oversell-btn box-grow-1">
  21. <template v-if="item.goods_stock === 0">已售罄</template>
  22. <template v-else-if="!start_time">活动未开始</template>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import bdService from '@/components/page-component/goods/bd-service.vue';
  28. export default {
  29. name: 'app-bottom-button',
  30. props: {
  31. selectAttr: Object,
  32. selectGroupAttrId: {
  33. type: [String, Number]
  34. },
  35. is_alone_buy: {
  36. type: Number,
  37. },
  38. groups: {
  39. type: Array,
  40. default() {
  41. return [];
  42. }
  43. },
  44. level_show: {
  45. type: Number,
  46. default() {
  47. return 0;
  48. }
  49. },
  50. member_price_min: {
  51. type: [String, Number],
  52. default() {
  53. return '0.00';
  54. }
  55. },
  56. price: {
  57. type: String,
  58. default() {
  59. return '0.00';
  60. }
  61. },
  62. price_member_min: {
  63. type: Number,
  64. default() {
  65. return 0;
  66. }
  67. },
  68. pt: {
  69. type: Boolean,
  70. },
  71. item: Object,
  72. start_time: Boolean,
  73. end_time: Boolean,
  74. theme: Object,
  75. url: String,
  76. name: String,
  77. singlePrice: String
  78. },
  79. data() {
  80. return {
  81. group_price: '',
  82. disable: 'disable'
  83. }
  84. },
  85. mounted() {
  86. this.get_group();
  87. },
  88. methods: {
  89. turnOn(bool) {
  90. this.$emit('click', bool);
  91. },
  92. get_group() {
  93. if (this.$validation.isEmpty(this.selectAttr)) {
  94. if (this.level_show === 1) {
  95. if (Number(this.member_price_min) === 0) {
  96. this.group_price = '免费';
  97. } else {
  98. this.group_price = `¥${this.member_price_min}`;
  99. }
  100. } else {
  101. if (Number(this.groups[0].price_min) === 0) {
  102. this.group_price = '免费';
  103. } else {
  104. this.group_price = `¥${this.groups[0].price_min}`;
  105. }
  106. }
  107. } else {
  108. if (this.level_show === 1) {
  109. if (Number(this.selectAttr.price_member) === 0) {
  110. this.group_price = '免费';
  111. } else {
  112. this.group_price = `¥${this.selectAttr.price_member}`;
  113. }
  114. } else {
  115. if (Number(this.selectAttr.price) === 0) {
  116. this.group_price = '免费';
  117. } else {
  118. this.group_price = `¥${this.selectAttr.price}`;
  119. }
  120. }
  121. }
  122. },
  123. router() {
  124. uni.reLaunch({
  125. url: `/pages/index/index`
  126. });
  127. }
  128. },
  129. computed: {
  130. // // 单价
  131. // singlePrice() {
  132. // if (this.pt) return;
  133. // if (this.$validation.isEmpty(this.selectAttr)) {
  134. // if (this.level_show === 1) {
  135. // if (this.price_member_min === 0) {
  136. // return '免费';
  137. // } else {
  138. // let price = this.price_member_min;
  139. // return `¥${price.toFixed(2)}`
  140. // }
  141. // } else {
  142. // if (Number(this.price) === 0) {
  143. // return '免费';
  144. // } else {
  145. // return `¥${this.price}`
  146. // }
  147. // }
  148. // } else {
  149. // if (this.level_show === 1) {
  150. // if (Number(this.selectAttr.price_member) === 0) {
  151. // return '免费';
  152. // } else {
  153. // return `¥${this.selectAttr.price_member}`;
  154. // }
  155. // } else {
  156. // if (Number(this.price) === 0) {
  157. // return '免费';
  158. // } else {
  159. // return `¥${this.selectAttr.price}`
  160. // }
  161. // }
  162. // }
  163. // },
  164. set_group_num() {
  165. for (let i = 0; i < this.groups.length; i++) {
  166. if (this.groups[i].groups.id == this.selectGroupAttrId) {
  167. return i;
  168. }
  169. }
  170. } },
  171. watch: {
  172. selectAttr: {
  173. handler() {
  174. if (this.pt) {
  175. if (this.$validation.isEmpty(this.selectAttr)) {
  176. if (this.level_show === 1) {
  177. if (Number(this.member_price_min) === 0) {
  178. this.group_price = '免费';
  179. } else {
  180. this.group_price = `¥${this.member_price_min}`;
  181. }
  182. } else {
  183. if (Number(this.groups[0].price_min) === 0) {
  184. this.group_price = '免费';
  185. } else {
  186. this.group_price = `¥${this.groups[0].price_min}`;
  187. }
  188. }
  189. } else {
  190. if (this.level_show === 1) {
  191. if (Number(this.selectAttr.price_member) === 0) {
  192. this.group_price = '免费';
  193. } else {
  194. this.group_price = `¥${this.selectAttr.price_member}`;
  195. }
  196. } else {
  197. if (Number(this.selectAttr.price) === 0) {
  198. this.group_price = '免费';
  199. } else {
  200. this.group_price = `¥${this.selectAttr.price}`;
  201. }
  202. }
  203. }
  204. }
  205. },
  206. immediate: true,
  207. deep: true,
  208. },
  209. groups: {
  210. handler(data) {
  211. if (data.length > 0) {
  212. this.$nextTick(() => {
  213. this.get_group();
  214. })
  215. }
  216. },
  217. immediate: true
  218. }
  219. },
  220. components: {
  221. bdService
  222. }
  223. }
  224. </script>
  225. <style scoped lang="scss">
  226. .app-single-button {
  227. background-color: #feeeee;
  228. text {
  229. color: #ff5c5c;
  230. }
  231. }
  232. .app-pt-button {
  233. background: linear-gradient(140deg, #ff9460, #ff5c5c);
  234. text {
  235. color: white;
  236. }
  237. }
  238. .app-but {
  239. height: #{110rpx};
  240. width: 50%;
  241. }
  242. .price {
  243. font-size: #{24rpx};
  244. margin-top: #{5rpx};
  245. }
  246. .app-text {
  247. font-size: #{20rpx};
  248. }
  249. .text {
  250. color: #ffffff;
  251. }
  252. .bd-bottom {
  253. height: 110upx;
  254. width: 750upx;
  255. padding: 20upx 24upx;
  256. }
  257. .bd-back {
  258. width: 66upx;
  259. height: 100%;
  260. margin-right: 20upx;
  261. font-size: 20upx;
  262. color: #888888;
  263. }
  264. .bd-btn-half {
  265. width: 50%;
  266. }
  267. .bd-icon {
  268. width: 30upx;
  269. height: 30upx;
  270. margin-bottom: 8upx;
  271. }
  272. .bd-text {
  273. font-size: 20upx;
  274. color: #888888;
  275. line-height: 1;
  276. }
  277. .bd-btn {
  278. text-align: center;
  279. font-size: 26upx;
  280. border-radius: 35upx;
  281. }
  282. .bd-btn-left {
  283. border-top-right-radius: 0;
  284. border-bottom-right-radius: 0;
  285. }
  286. .bd-btn-right {
  287. border-top-left-radius: 0;
  288. border-bottom-left-radius: 0;
  289. color: #ffffff;
  290. }
  291. .bd-oversell-btn {
  292. background-color: #CDCDCD;
  293. color: #ffffff;
  294. line-height: 70upx;
  295. }
  296. .bd-btn-left {
  297. border-top-right-radius: 0;
  298. border-bottom-right-radius: 0;
  299. }
  300. .bd-btn-right {
  301. border-top-left-radius: 0;
  302. border-bottom-left-radius: 0;
  303. }
  304. </style>