cm-price-activity.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template name="cm-price">
  2. <!-- 商品详情价格判断 -->
  3. <view class="wrap-main">
  4. <!-- 协销 -->
  5. <view class="wrap-main-item">
  6. <view class="p-price tui-skeleton-fillet">
  7. <text class="txt sm">¥</text> <text class="txt big">{{ showIndexOfMoney }} </text>
  8. <text class="txt sm">{{ smallMoney }} </text>
  9. </view>
  10. <view class="floor-item-act" v-if="product.activeStatus == 1 && product.ladderList.length > 0">
  11. <text class="tag tag-01">促销</text>
  12. <view class="tag tag-02" @click.stop="clickPopupShow()">活动价</view>
  13. </view>
  14. </view>
  15. <!--促销活动弹窗提示-->
  16. <tui-bottom-popup :radius="true" :show="popupShow" @close="hidePopup()">
  17. <view class="tui-popup-box clearfix">
  18. <template v-if="product.activeStatus == 1">
  19. <view class="tui-scrollview-box">
  20. <view class="ladder-main clearfix">
  21. <view class="ladder-item">
  22. <view class="ladder-item-td">购买数</view> <view class="ladder-item-td">价格</view>
  23. </view>
  24. <view class="ladder-item" v-for="(ladd, index) in product.ladderList" :key="index">
  25. <view class="ladder-item-td">{{ ladd.buyNum }}</view>
  26. <view class="ladder-item-td">{{ ladd.buyPrice | NumFormat }}</view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <template v-else>
  32. <view class="tui-scrollview-box">
  33. <view class="box-text">
  34. <text>促销时间:</text>
  35. <text class="txt" v-if="product.promotion.status == 1">不限时</text>
  36. <text class="txt" v-else
  37. >{{ product.promotion.beginTime }}~{{ product.promotion.endTime }}</text
  38. >
  39. </view>
  40. <view class="box-title" v-show="product.promotion.mode == 2">
  41. <text>购买{{ product.promotion.name }}商品,满</text>
  42. <text class="txt"
  43. >¥{{
  44. product.promotion == null ? '0.00' : product.promotion.touchPrice | NumFormat
  45. }}</text
  46. >减
  47. <text class="txt"
  48. >¥{{
  49. product.promotion == null ? '0.00' : product.promotion.reducedPrice | NumFormat
  50. }}</text
  51. >
  52. </view>
  53. <view class="box-title" v-show="product.promotion.mode == 3">
  54. <text>购买{{ product.promotion.name }}商品,满</text>
  55. <text class="txt"
  56. >¥{{
  57. product.promotion == null ? '0.00' : product.promotion.touchPrice | NumFormat
  58. }}</text
  59. >赠送商品
  60. </view>
  61. <view class="box-product" v-show="product.promotion.mode == 3">
  62. <view
  63. class="box-product-main"
  64. v-for="(item, index) in product.promotion.productGifts"
  65. :key="index"
  66. >
  67. <view class="image"><image :src="item.mainImage" mode="widthFix"></image></view>
  68. <view class="info">
  69. <view class="name">{{ item.productName }}</view>
  70. <view class="num">X{{ item.productCount }}</view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <view class="tui-right-flex tui-popup-btn">
  77. <view class="tui-flex-1">
  78. <view
  79. class="tui-button"
  80. v-if="product.promotion.type == 2"
  81. @click="goGoodActiveFn(product.promotion.id)"
  82. >更多凑单商品</view
  83. >
  84. <view class="tui-button" v-else @click="hidePopup()">了解</view>
  85. </view>
  86. </view>
  87. </view>
  88. </tui-bottom-popup>
  89. <!-- </template> -->
  90. </view>
  91. </template>
  92. <script>
  93. import { mapGetters } from 'vuex'
  94. export default {
  95. name: 'cm-price',
  96. props: {
  97. product: {
  98. type: Object
  99. },
  100. userIdentity: {
  101. type: Number,
  102. default: 2
  103. },
  104. ladderList: {
  105. type: Array
  106. },
  107. promotion: {
  108. type: Object
  109. }
  110. },
  111. data() {
  112. return {
  113. productInfo: {},
  114. popupShow: false,
  115. promotionType: 0,
  116. ableUserMoney: '',
  117. showIndexOfMoney: '',
  118. smallMoney: ''
  119. }
  120. },
  121. filters: {
  122. NumFormat: function(text) {
  123. //处理金额
  124. return Number(text).toFixed(2)
  125. }
  126. },
  127. created() {
  128. this.InfoData(this.product)
  129. },
  130. computed: {
  131. ...mapGetters(['hasLogin', 'isWxAuthorize', 'isIphoneX'])
  132. },
  133. methods: {
  134. InfoData(data) {
  135. this.productInfo = data
  136. if (this.productInfo.price == 0) {
  137. this.showIndexOfMoney = '0'
  138. this.smallMoney = '.00'
  139. } else {
  140. this.ableUserMoney = this.$api.FormatMoney(this.productInfo.price)
  141. let i = this.ableUserMoney.toString().lastIndexOf('.')
  142. if (i == -1) {
  143. this.showIndexOfMoney = this.$api.FormatMoney(this.ableUserMoney)
  144. this.smallMoney = '.00'
  145. } else {
  146. this.smallMoney = this.ableUserMoney.toString().substring(i, i + 3)
  147. this.showIndexOfMoney = this.$api.FormatMoney(this.ableUserMoney.toString().substring(0, i))
  148. if (this.smallMoney.length == 2) {
  149. //补0,实际上用不着
  150. this.smallMoney = this.smallMoney + '0'
  151. }
  152. }
  153. }
  154. console.log('this.showIndexOfMoney', this.showIndexOfMoney)
  155. console.log('this.smallMoney', this.smallMoney)
  156. },
  157. clickPopupShow(type) {
  158. if (this.product.ladderList.length > 0) {
  159. this.popupShow = true
  160. this.promotionType = type
  161. }
  162. },
  163. hidePopup() {
  164. this.popupShow = false
  165. },
  166. promotionFormat(promo) {
  167. //促销活动类型数据处理
  168. if (promo != null) {
  169. if (promo.type == 1 && promo.mode == 1) {
  170. return true
  171. } else {
  172. return false
  173. }
  174. }
  175. return false
  176. },
  177. goUpgradeApply() {
  178. this.$api.navigateTo('/pages/login/apply')
  179. },
  180. loginClick() {
  181. this.$api.navigateTo('/pages/login/login')
  182. },
  183. goGoodActiveFn(id) {
  184. this.$parent.popupShow = false
  185. this.$api.navigateTo('/pages/goods/goods-active?id=' + id)
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss">
  191. .tui-flex-1 {
  192. flex: 1;
  193. }
  194. .tui-popup-box {
  195. position: relative;
  196. box-sizing: border-box;
  197. min-height: 220rpx;
  198. padding: 24rpx 24rpx 0 24rpx;
  199. }
  200. .tui-scrollview-box {
  201. width: 100%;
  202. height: auto;
  203. float: left;
  204. box-sizing: border-box;
  205. .ladder-main {
  206. width: 100%;
  207. border: 1px solid rgba(225, 86, 22, 0.3);
  208. border-radius: 10rpx;
  209. .ladder-item {
  210. width: 100%;
  211. height: 80rpx;
  212. float: left;
  213. border-bottom: 1px solid rgba(225, 86, 22, 0.3);
  214. &:nth-child(1) {
  215. .ladder-item-td {
  216. color: #333333;
  217. }
  218. }
  219. &:last-child {
  220. border-bottom: none;
  221. }
  222. .ladder-item-td {
  223. width: 50%;
  224. text-align: center;
  225. line-height: 80rpx;
  226. font-size: $font-size-24;
  227. color: $color-system;
  228. box-sizing: border-box;
  229. float: left;
  230. &:nth-child(1) {
  231. border-right: 1px solid rgba(225, 86, 22, 0.3);
  232. }
  233. }
  234. }
  235. }
  236. .box-title {
  237. font-size: $font-size-26;
  238. color: $text-color;
  239. text-align: left;
  240. line-height: 56rpx;
  241. .txt {
  242. color: $color-system;
  243. margin: 0 8rpx;
  244. }
  245. }
  246. .box-text {
  247. font-size: $font-size-26;
  248. color: $text-color;
  249. text-align: left;
  250. line-height: 56rpx;
  251. .txt {
  252. color: #ff457b;
  253. }
  254. }
  255. .box-product {
  256. width: 100%;
  257. height: auto;
  258. margin-top: 20rpx;
  259. .title {
  260. font-size: $font-size-24;
  261. color: $text-color;
  262. text-align: left;
  263. line-height: 54rpx;
  264. }
  265. .box-product-main {
  266. width: 100%;
  267. height: 136rpx;
  268. float: left;
  269. margin: 10rpx 0;
  270. .image {
  271. width: 134rpx;
  272. height: 134rpx;
  273. border: 1px solid #ebebeb;
  274. float: left;
  275. image {
  276. width: 100%;
  277. height: 100%;
  278. display: block;
  279. }
  280. }
  281. .info {
  282. width: 540rpx;
  283. height: 134rpx;
  284. float: left;
  285. margin-left: 16rpx;
  286. position: relative;
  287. .name {
  288. width: 100%;
  289. float: left;
  290. line-height: 40rpx;
  291. font-size: $font-size-28;
  292. color: $text-color;
  293. -o-text-overflow: ellipsis;
  294. text-overflow: ellipsis;
  295. display: -webkit-box;
  296. word-break: break-all;
  297. -webkit-box-orient: vertical;
  298. -webkit-line-clamp: 2;
  299. overflow: hidden;
  300. }
  301. .num {
  302. width: 100%;
  303. height: 44rpx;
  304. font-size: $font-size-24;
  305. color: $text-color;
  306. text-align: left;
  307. line-height: 44rpx;
  308. position: absolute;
  309. bottom: 0;
  310. left: 0;
  311. }
  312. }
  313. }
  314. }
  315. }
  316. .tui-popup-btn {
  317. width: 100%;
  318. height: auto;
  319. float: left;
  320. margin-top: 24rpx;
  321. .tui-button {
  322. width: 100%;
  323. height: 88rpx;
  324. background: $btn-confirm;
  325. line-height: 88rpx;
  326. text-align: center;
  327. color: #ffffff;
  328. font-size: $font-size-28;
  329. border-radius: 44rpx;
  330. }
  331. }
  332. // .wrap-main{
  333. // .floor-item-act{
  334. // &::after{
  335. // content: "";
  336. // display: block;
  337. // clear: both;
  338. // }
  339. // .tag{
  340. // margin-right: 10rpx;
  341. // float: left;
  342. // }
  343. // }
  344. // }
  345. </style>