cm-price.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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 | formatPrice }}</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 | formatPrice
  44. }}</text
  45. >减
  46. <text class="txt"
  47. >¥{{
  48. product.promotion == null ? '0.00' : product.promotion.reducedPrice | formatPrice
  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 | formatPrice
  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. created() {
  121. this.InfoData(this.product)
  122. },
  123. computed: {
  124. ...mapGetters(['hasLogin', 'isWxAuthorize', 'isIphoneX'])
  125. },
  126. methods: {
  127. InfoData(data) {
  128. this.productInfo = data
  129. if (this.productInfo.price == 0) {
  130. this.showIndexOfMoney = '0'
  131. this.smallMoney = '.00'
  132. } else {
  133. this.ableUserMoney = this.$api.FormatMoney(this.productInfo.price)
  134. let i = this.ableUserMoney.toString().lastIndexOf('.')
  135. if (i == -1) {
  136. this.showIndexOfMoney = this.$api.FormatMoney(this.ableUserMoney)
  137. this.smallMoney = '.00'
  138. } else {
  139. this.smallMoney = this.ableUserMoney.toString().substring(i)
  140. this.showIndexOfMoney = this.$api.FormatMoney(this.ableUserMoney.toString().substring(0, i))
  141. if (this.smallMoney.length == 2) {
  142. //补0,实际上用不着
  143. this.smallMoney = this.smallMoney + '0'
  144. }
  145. }
  146. }
  147. console.log('this.showIndexOfMoney', this.showIndexOfMoney)
  148. console.log('this.smallMoney', this.smallMoney)
  149. },
  150. clickPopupShow(type) {
  151. if (this.product.ladderList.length > 0) {
  152. this.popupShow = true
  153. this.promotionType = type
  154. }
  155. },
  156. hidePopup() {
  157. this.popupShow = false
  158. },
  159. promotionFormat(promo) {
  160. //促销活动类型数据处理
  161. if (promo != null) {
  162. if (promo.type == 1 && promo.mode == 1) {
  163. return true
  164. } else {
  165. return false
  166. }
  167. }
  168. return false
  169. },
  170. goUpgradeApply() {
  171. this.$api.navigateTo('/pages/login/apply')
  172. },
  173. loginClick() {
  174. this.$api.navigateTo('/pages/login/login')
  175. },
  176. goGoodActiveFn(id) {
  177. this.$parent.popupShow = false
  178. this.$api.navigateTo('/pages/goods/goods-active?id=' + id)
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss">
  184. .tui-flex-1 {
  185. flex: 1;
  186. }
  187. .tui-popup-box {
  188. position: relative;
  189. box-sizing: border-box;
  190. min-height: 220rpx;
  191. padding: 24rpx 24rpx 0 24rpx;
  192. }
  193. .tui-scrollview-box {
  194. width: 100%;
  195. height: auto;
  196. float: left;
  197. box-sizing: border-box;
  198. .ladder-main {
  199. width: 100%;
  200. border: 1px solid rgba(225, 86, 22, 0.3);
  201. border-radius: 10rpx;
  202. .ladder-item {
  203. width: 100%;
  204. height: 80rpx;
  205. float: left;
  206. border-bottom: 1px solid rgba(225, 86, 22, 0.3);
  207. &:nth-child(1) {
  208. .ladder-item-td {
  209. color: #333333;
  210. }
  211. }
  212. &:last-child {
  213. border-bottom: none;
  214. }
  215. .ladder-item-td {
  216. width: 50%;
  217. text-align: center;
  218. line-height: 80rpx;
  219. font-size: $font-size-24;
  220. color: $color-system;
  221. box-sizing: border-box;
  222. float: left;
  223. &:nth-child(1) {
  224. border-right: 1px solid rgba(225, 86, 22, 0.3);
  225. }
  226. }
  227. }
  228. }
  229. .box-title {
  230. font-size: $font-size-26;
  231. color: $text-color;
  232. text-align: left;
  233. line-height: 56rpx;
  234. .txt {
  235. color: $color-system;
  236. margin: 0 8rpx;
  237. }
  238. }
  239. .box-text {
  240. font-size: $font-size-26;
  241. color: $text-color;
  242. text-align: left;
  243. line-height: 56rpx;
  244. .txt {
  245. color: #ff457b;
  246. }
  247. }
  248. .box-product {
  249. width: 100%;
  250. height: auto;
  251. margin-top: 20rpx;
  252. .title {
  253. font-size: $font-size-24;
  254. color: $text-color;
  255. text-align: left;
  256. line-height: 54rpx;
  257. }
  258. .box-product-main {
  259. width: 100%;
  260. height: 136rpx;
  261. float: left;
  262. margin: 10rpx 0;
  263. .image {
  264. width: 134rpx;
  265. height: 134rpx;
  266. border: 1px solid #ebebeb;
  267. float: left;
  268. image {
  269. width: 100%;
  270. height: 100%;
  271. display: block;
  272. }
  273. }
  274. .info {
  275. width: 540rpx;
  276. height: 134rpx;
  277. float: left;
  278. margin-left: 16rpx;
  279. position: relative;
  280. .name {
  281. width: 100%;
  282. float: left;
  283. line-height: 40rpx;
  284. font-size: $font-size-28;
  285. color: $text-color;
  286. -o-text-overflow: ellipsis;
  287. text-overflow: ellipsis;
  288. display: -webkit-box;
  289. word-break: break-all;
  290. -webkit-box-orient: vertical;
  291. -webkit-line-clamp: 2;
  292. overflow: hidden;
  293. }
  294. .num {
  295. width: 100%;
  296. height: 44rpx;
  297. font-size: $font-size-24;
  298. color: $text-color;
  299. text-align: left;
  300. line-height: 44rpx;
  301. position: absolute;
  302. bottom: 0;
  303. left: 0;
  304. }
  305. }
  306. }
  307. }
  308. }
  309. .tui-popup-btn {
  310. width: 100%;
  311. height: auto;
  312. float: left;
  313. margin-top: 24rpx;
  314. .tui-button {
  315. width: 100%;
  316. height: 88rpx;
  317. background: $btn-confirm;
  318. line-height: 88rpx;
  319. text-align: center;
  320. color: #ffffff;
  321. font-size: $font-size-28;
  322. border-radius: 44rpx;
  323. }
  324. }
  325. // .wrap-main{
  326. // .floor-item-act{
  327. // &::after{
  328. // content: "";
  329. // display: block;
  330. // clear: both;
  331. // }
  332. // .tag{
  333. // margin-right: 10rpx;
  334. // float: left;
  335. // }
  336. // }
  337. // }
  338. </style>