cm-price.vue 8.3 KB

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