index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. <template>
  2. <view class="page">
  3. <navBar title="定制我家的主灯" :back="true" color="black" background="white" />
  4. <image :src="picUrl+'/static/other/noMain_img3.png'" mode="" class="topBg"></image>
  5. <view class="content">
  6. <view class="topBox">
  7. <view class="lTxt">
  8. <image src="/static/index/water.png" mode="" class="water1"></image>
  9. <view class="main">
  10. <image src="/static/index/halfCircle_275.png" mode="" style="width: 56rpx;height: 56rpx;">
  11. </image>
  12. <text style="z-index: 3;position: relative;">定制我家的主灯</text>
  13. </view>
  14. </view>
  15. <view class="rDes">
  16. <view class="con">
  17. 详情
  18. </view>
  19. <image src="/static/index/halfRight.png" mode="" style="width: 24rpx;height: 8rpx;">
  20. </image>
  21. </view>
  22. </view>
  23. <view class="label" @click="handleOpenOrClose(1)">
  24. <view class="txt">
  25. 户型
  26. </view>
  27. <image :src="addOrLessIcon1" mode="" class="" :style="{height:addOrLessIcon1=='/static/index/shortLine.png'
  28. ?'2rpx':'22rpx'}" style="width: 22rpx;margin-right: 56rpx;">
  29. </image>
  30. </view>
  31. <view class="parms">
  32. <view v-if="show1" @click="handleSel1('hx',item,index)" class="item "
  33. :class="[currHouseIndex==index?'act':'']" v-for="(item,index) in houseTypeList">
  34. {{item.value}}
  35. </view>
  36. </view>
  37. <view class="label" @click="handleOpenOrClose(2)">
  38. <view class="txt">
  39. 系列
  40. </view>
  41. <image :src="addOrLessIcon2" mode="" class="" :style="{height:addOrLessIcon2=='/static/index/shortLine.png'
  42. ?'2rpx':'22rpx'}" style="width: 22rpx;margin-right: 56rpx;">
  43. </image>
  44. </view>
  45. <view class="parms">
  46. <view v-if="show2" @click="handleSel1('xl',item,index)" class="item "
  47. :class="[currHouseIndex5==index?'act':'']" v-for="(item,index) in serTypeList">
  48. {{item.value}}
  49. </view>
  50. </view>
  51. <view class="label" style="margin-bottom:32rpx;" @click="toSel('挑选客厅灯',1)">
  52. <view class="txt">
  53. 挑选客厅灯
  54. </view>
  55. <image src="/static/index/more.png" mode="" class="" style="width: 44rpx;height: 44rpx;">
  56. </image>
  57. </view>
  58. <view class="parms3">
  59. <image @click="handleSel('kt',item,index)" class="item3 " :src="picBase+item.cover"
  60. :class="[selKt.includes(item)?'act3':'']" v-for="(item,index) in brandTypeList">
  61. </image>
  62. </view>
  63. <view class="label" style="margin-bottom:32rpx;" @click="toSel('挑选餐厅灯',2)">
  64. <view class="txt">
  65. 挑选餐厅灯
  66. </view>
  67. <image src="/static/index/more.png" mode="" class="" style="width: 44rpx;height: 44rpx;">
  68. </image>
  69. </view>
  70. <view class="parms3">
  71. <image @click="handleSel('ct',item,index)" class="item3 " :src="picBase+item.cover"
  72. :class="[selCt.includes(item)?'act3':'']" v-for="(item,index) in lockTypeList">
  73. </image>
  74. </view>
  75. <view class="label" style="margin-bottom:32rpx;" @click="toSel('挑选卧室灯',3)">
  76. <view class="txt">
  77. 挑选卧室灯
  78. </view>
  79. <image src="/static/index/more.png" mode="" class="" style="width: 44rpx;height: 44rpx;">
  80. </image>
  81. </view>
  82. <view class="parms3">
  83. <image @click="handleSel('ws',item,index)" class="item3 " :src="picBase+item.cover"
  84. :class="[selWs.includes(item)?'act3':'']" v-for="(item,index) in chuanglianTypeList">
  85. </image>
  86. </view>
  87. <view class="label" style="margin-bottom:32rpx;" @click="toSel('挑选阳台灯',4)">
  88. <view class="txt">
  89. 挑选阳台灯
  90. </view>
  91. <image src="/static/index/more.png" mode="" class="" style="width: 44rpx;height: 44rpx;">
  92. </image>
  93. </view>
  94. <view class="parms3">
  95. <image @click="handleSel('yt',item,index)" class="item3 " :src="picBase+item.cover"
  96. :class="[selYt.includes(item)?'act3':'']" v-for="(item,index) in pannelTypeList">
  97. </image>
  98. </view>
  99. </view>
  100. <view class="rule" @click="goRule">
  101. <image src="/static/index/ruleImg.png" mode=""></image>
  102. <view class="txt">
  103. 挑选规则
  104. </view>
  105. </view>
  106. <view class="bot">
  107. <view class="left" @click="showConfig=true">
  108. <view class="price">
  109. ¥{{totalPrice.toFixed(2)}}
  110. </view>
  111. <!-- <image src="/static/index/arrDown.png" mode=""></image> -->
  112. <image v-if="!showConfig" src="/static/index/arrDown.png" mode="" @click="showConfig=true"></image>
  113. <image v-else src="/static/index/arrUp.png" mode="" @click="showConfig=false"></image>
  114. </view>
  115. <view class="right" @click="previewConfig">
  116. 预览配置
  117. </view>
  118. </view>
  119. <u-popup :show="showConfig" @close="close" @open="open" round='10'>
  120. <view class="topBar" style="">
  121. <view class="left">
  122. </view>
  123. <view class="cen">
  124. 清单
  125. </view>
  126. <view class="close" @click="showConfig=false">
  127. <u-icon name="close"></u-icon>
  128. </view>
  129. </view>
  130. <view class="pupopCon">
  131. <view class="item">
  132. <view class="top">
  133. <view class="name">
  134. 户型
  135. </view>
  136. <view class="info">
  137. {{selHx.value}}
  138. </view>
  139. </view>
  140. </view>
  141. <view class="item">
  142. <view class="top">
  143. <view class="name">
  144. 系列
  145. </view>
  146. <view class="info">
  147. {{selXl.value}}
  148. </view>
  149. </view>
  150. </view>
  151. <view class="item">
  152. <view class="top">
  153. <view class="name">
  154. 客厅灯
  155. </view>
  156. <view class="info">
  157. {{selKt?1:0}}
  158. </view>
  159. </view>
  160. </view>
  161. <view class="item">
  162. <view class="top">
  163. <view class="name">
  164. 餐厅灯
  165. </view>
  166. <view class="info">
  167. {{selCt?1:0}}
  168. </view>
  169. </view>
  170. </view>
  171. <view class="item">
  172. <view class="top">
  173. <view class="name">
  174. 卧室灯
  175. </view>
  176. <view class="info">
  177. {{selWs.length}}
  178. </view>
  179. </view>
  180. </view>
  181. <view class="item">
  182. <view class="top">
  183. <view class="name">
  184. 阳台灯
  185. </view>
  186. <view class="info">
  187. {{selYt?1:0}}
  188. </view>
  189. </view>
  190. </view>
  191. </view>
  192. </u-popup>
  193. <u-modal :show="showHuxing" @confirm="showHuxing=false" title="户型" :content='content' confirmColor="#F7790C">
  194. <view class="tipContent">
  195. <view class="card">
  196. <view class="item">
  197. <view class="left">
  198. {{selHx.extend.title}}
  199. </view>
  200. <view class="right">
  201. ¥{{selHx.extend.money}}
  202. </view>
  203. </view>
  204. <view class="item">
  205. <view class="left" style="font-weight: normal;">
  206. 灯具
  207. </view>
  208. <view class="right">
  209. {{selHx.extend.lampCount}}
  210. </view>
  211. </view>
  212. </view>
  213. <view class="tip">
  214. <image src="/static/index/more.png" mode=""></image>
  215. {{selHx.extend.remark}}
  216. </view>
  217. </view>
  218. </u-modal>
  219. <u-modal :show="showMissItem" title="提示" @confirm="showMissItem=false" content='' confirmColor="#F7790C">
  220. <view class="tip2">
  221. 客厅灯具少选1盏!
  222. </view>
  223. </u-modal>
  224. </view>
  225. </template>
  226. <script>
  227. import {
  228. getIndexConfigReq,
  229. } from '@/api/test/index.js'
  230. import {
  231. getDataMoneyReq
  232. } from '@/api/index/index.js'
  233. export default {
  234. components: {
  235. },
  236. data() {
  237. return {
  238. picUrl: this.$picUrl,
  239. picBase: this.$picBase,
  240. addOrLessIcon1: '/static/index/add.png',
  241. addOrLessIcon2: '/static/index/add.png',
  242. addOrLessIcon3: '/static/index/add.png',
  243. addOrLessIcon4: '/static/index/add.png',
  244. addOrLessIcon5: '/static/index/add.png',
  245. // lessIcon: require('/static/index/shortLine.png'),
  246. show1: false,
  247. show2: false,
  248. show3: false,
  249. show4: false,
  250. show5: false,
  251. showConfig: false,
  252. showHuxing: false,
  253. showMissItem: false,
  254. seledKetingItem: null,
  255. currHouseIndex: 0,
  256. currHouseIndex1: 0,
  257. currHouseIndex2: 0,
  258. currHouseIndex3: 0,
  259. currHouseIndex4: 0,
  260. currHouseIndex5: 0,
  261. currHouseIndex6: 0,
  262. houseTypeList: [],
  263. brandTypeList: [],
  264. lockTypeList: [],
  265. pannelTypeList: [],
  266. chuanglianTypeList: [],
  267. serTypeList: [
  268. ],
  269. rule: null,
  270. selHx: null,
  271. selXl: null,
  272. selKt: [],
  273. selCt: [],
  274. selWs: [],
  275. selYt: [],
  276. totalPrice: 0,
  277. pConfig: -1,
  278. cutdownRatio: 1
  279. }
  280. },
  281. async onLoad(o) {
  282. let res = await getIndexConfigReq({
  283. type: 2
  284. })
  285. if (res.code == 0) {
  286. console.log('获取首页配置返回值-主灯: ', res);
  287. this.houseTypeList = res.data.house_type
  288. this.brandTypeList = res.data.living_room
  289. this.lockTypeList = res.data.dining_room_light
  290. this.serTypeList = res.data.series
  291. this.chuanglianTypeList = res.data.bedroom_lamp
  292. this.pannelTypeList = res.data.balcony_light
  293. // this.rule = res.data.rule.content
  294. this.selHx = res.data.house_type[0]
  295. this.selXl = res.data.series[0]
  296. this.selKt = [res.data.living_room[0]]
  297. this.selCt = [res.data.dining_room_light[0]]
  298. this.selWs = [res.data.bedroom_lamp[0]]
  299. this.selYt = [res.data.balcony_light[0]]
  300. let wsIds1 = []
  301. this.selKt.forEach((item, index) => {
  302. wsIds1.push(item.id)
  303. })
  304. let wsIds2 = []
  305. this.selCt.forEach((item, index) => {
  306. wsIds2.push(item.id)
  307. })
  308. let wsIds3 = []
  309. this.selWs.forEach((item, index) => {
  310. wsIds3.push(item.id)
  311. })
  312. let wsIds4 = []
  313. this.selYt.forEach((item, index) => {
  314. wsIds4.push(item.id)
  315. })
  316. this.getPrice(2, this.selHx.id, this.selXl.id, wsIds1.sort().join(','), wsIds2.sort().join(','), wsIds3
  317. .sort().join(','),
  318. wsIds4.sort().join(','))
  319. } else {
  320. uni.showToast({
  321. title: res.message,
  322. icon: 'none'
  323. })
  324. }
  325. },
  326. onShow() {
  327. this.cutdownRatio = this.$getCutDown()
  328. console.log('哪种折扣价格', this.cutdownRatio);
  329. console.log('确定选择的那一项', getApp().chooseItem_kt);
  330. if (getApp().chooseItem_kt) {
  331. let index = getApp().index_kt
  332. let item = getApp().chooseItem_kt
  333. let type = ''
  334. if (getApp().chooseType == '挑选客厅灯') {
  335. type = 'kt'
  336. } else if (getApp().chooseType == '挑选餐厅灯') {
  337. type = 'ct'
  338. } else if (getApp().chooseType == '挑选卧室灯') {
  339. type = 'ws'
  340. } else {
  341. type = 'yt'
  342. }
  343. this.handleSel(type, item, index, 2)
  344. getApp().chooseItem_kt = null
  345. getApp().index_kt = null
  346. getApp().chooseType = null
  347. }
  348. },
  349. methods: {
  350. async getPrice(type = 2, house_type, series, drawing_lamp, canteen_lamp, bedroom_lamp, balcony_lamp) {
  351. let res = await getDataMoneyReq({
  352. type,
  353. house_type,
  354. series,
  355. drawing_lamp,
  356. canteen_lamp,
  357. bedroom_lamp,
  358. balcony_lamp
  359. })
  360. if (res.code == 0) {
  361. console.log('配置价格-主灯: ', res)
  362. this.totalPrice = res.data.money * this.cutdownRatio
  363. this.pConfig = res.data.id
  364. } else {
  365. uni.showToast({
  366. title: res.message,
  367. icon: 'none'
  368. })
  369. }
  370. },
  371. goRule() {
  372. getApp().content = this.rule
  373. uni.navigateTo({
  374. url: '/pages/index/rule/index?type=main'
  375. })
  376. },
  377. toSel(name, type) {
  378. if (type == 1) {
  379. getApp().typeList = this.brandTypeList
  380. } else if (type == 2) {
  381. getApp().typeList = this.lockTypeList
  382. } else if (type == 3) {
  383. getApp().typeList = this.chuanglianTypeList
  384. } else {
  385. getApp().typeList = this.pannelTypeList
  386. }
  387. uni.navigateTo({
  388. url: '/pages/index/mainList/index?name=' + name
  389. })
  390. },
  391. handleOpenOrClose(i) {
  392. if (this['addOrLessIcon' + i] == '/static/index/shortLine.png') {
  393. this['addOrLessIcon' + i] = '/static/index/add.png'
  394. this['show' + i] = false
  395. } else if (this['addOrLessIcon' + i] == '/static/index/add.png') {
  396. this['addOrLessIcon' + i] = '/static/index/shortLine.png'
  397. this['show' + i] = true
  398. }
  399. },
  400. handleSel1(type, item, index) {
  401. if (type == 'hx') {
  402. this.currHouseIndex = index
  403. this.selHx = item
  404. } else {
  405. this.currHouseIndex5 = index
  406. this.selXl = item
  407. }
  408. let wsIds1 = []
  409. this.selKt.forEach((item, index) => {
  410. wsIds1.push(item.id)
  411. })
  412. let wsIds2 = []
  413. this.selCt.forEach((item, index) => {
  414. wsIds2.push(item.id)
  415. })
  416. let wsIds3 = []
  417. this.selWs.forEach((item, index) => {
  418. wsIds3.push(item.id)
  419. })
  420. let wsIds4 = []
  421. this.selYt.forEach((item, index) => {
  422. wsIds4.push(item.id)
  423. })
  424. this.getPrice(2, this.selHx.id, this.selXl.id, wsIds1.sort().join(','), wsIds2.sort().join(','), wsIds3
  425. .sort().join(','),
  426. wsIds4.sort().join(','))
  427. },
  428. handleSel(type, item, index, mode = 1) {
  429. if (type == 'kt') {
  430. this.currHouseIndex3 = index
  431. if (!this.selKt.includes(item)) {
  432. this.selKt.push(item)
  433. } else {
  434. if (mode == 1) {
  435. let i = this.selKt.findIndex((item1, index1) => {
  436. return item1 == item
  437. })
  438. this.selKt.splice(i, 1)
  439. }
  440. }
  441. } else if (type == 'ct') {
  442. this.currHouseIndex2 = index
  443. if (!this.selCt.includes(item)) {
  444. this.selCt.push(item)
  445. } else {
  446. if (mode == 1) {
  447. let i = this.selCt.findIndex((item1, index1) => {
  448. return item1 == item
  449. })
  450. this.selCt.splice(i, 1)
  451. }
  452. }
  453. } else if (type == 'ws') {
  454. this.currHouseIndex4 = index
  455. if (!this.selWs.includes(item)) {
  456. this.selWs.push(item)
  457. } else {
  458. if (mode == 1) {
  459. let i = this.selWs.findIndex((item1, index1) => {
  460. return item1 == item
  461. })
  462. this.selWs.splice(i, 1)
  463. }
  464. }
  465. } else if (type == 'yt') {
  466. this.currHouseIndex6 = index
  467. if (!this.selYt.includes(item)) {
  468. this.selYt.push(item)
  469. } else {
  470. if (mode == 1) {
  471. let i = this.selYt.findIndex((item1, index1) => {
  472. return item1 == item
  473. })
  474. this.selYt.splice(i, 1)
  475. }
  476. }
  477. }
  478. let wsIds1 = []
  479. this.selKt.forEach((item, index) => {
  480. wsIds1.push(item.id)
  481. })
  482. let wsIds2 = []
  483. this.selCt.forEach((item, index) => {
  484. wsIds2.push(item.id)
  485. })
  486. let wsIds3 = []
  487. this.selWs.forEach((item, index) => {
  488. wsIds3.push(item.id)
  489. })
  490. let wsIds4 = []
  491. this.selYt.forEach((item, index) => {
  492. wsIds4.push(item.id)
  493. })
  494. this.getPrice(2, this.selHx.id, this.selXl.id, wsIds1.sort().join(','), wsIds2.sort().join(','), wsIds3
  495. .sort().join(','),
  496. wsIds4.sort().join(','))
  497. },
  498. previewConfig() {
  499. if (!this.selKt) {
  500. this.showMissItem = true
  501. return
  502. }
  503. if (this.selHx.value == '一室两厅' && this.selWs.length < 1) {
  504. this.showHuxing = true
  505. return
  506. } else if (this.selHx.value == '两室两厅' && this.selWs.length < 2) {
  507. this.showHuxing = true
  508. return
  509. } else if (this.selHx.value == '三室两厅' && this.selWs.length < 3) {
  510. this.showHuxing = true
  511. return
  512. }
  513. getApp().mainPreviewInfo = {
  514. hx: this.selHx,
  515. xl: this.selXl,
  516. kt: this.selKt,
  517. ct: this.selCt,
  518. ws: this.selWs,
  519. yt: this.selYt,
  520. price: this.totalPrice
  521. }
  522. getApp().pConfig = this.pConfig
  523. uni.navigateTo({
  524. url: '/pages/index/customMian/index'
  525. })
  526. }
  527. }
  528. }
  529. </script>
  530. <style lang="scss" scoped>
  531. @import "./index.scss";
  532. </style>