cm-price.vue 8.1 KB

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