cm-price.vue 8.5 KB

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