cm-price.vue 11 KB

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