index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view class="page">
  3. <navBar title="网络规划-全屋WiFi" :back="true" color="black" background="white" />
  4. <!-- <image :src="picUrl + '/static/other/c1.png'" mode="" class="topBg"></image> -->
  5. <image :src="picBase+topPic" mode="" class="topBg"></image>
  6. <view class="content">
  7. <view class="topBox">
  8. <view class="lTxt">
  9. <image src="/static/index/water.png" mode="" class="water1"></image>
  10. <view class="main">
  11. <image src="/static/index/halfCircle_275.png" mode="" style="width: 56rpx;height: 56rpx;">
  12. </image>
  13. <text style="z-index: 3;position: relative;">定制我家的全屋WiFi</text>
  14. </view>
  15. </view>
  16. <view class="rDes" @click="toRule">
  17. <view class="con">
  18. 详情
  19. </view>
  20. <image :src="picUrl+'/static/other/halfRight_b.png'" mode="" style="width: 25rpx;height: 15rpx;">
  21. </image>
  22. </view>
  23. </view>
  24. <view class="label" @click="handleOpenOrClose(1)"
  25. :style="{'margin-bottom':addOrLessIcon1=='/static/index/shortLine.png'?'32rpx':'0'}">
  26. <view class="txt">
  27. 户型
  28. </view>
  29. <image :src="addOrLessIcon1" mode="" class="" :style="{height:addOrLessIcon1=='/static/index/shortLine.png'
  30. ?'2rpx':'22rpx'}" style="width: 22rpx;margin-right: 56rpx;">
  31. </image>
  32. </view>
  33. <view class="parms">
  34. <view v-if="show1" @click="sel(item, index)" class="item " :class="[currHouseIndex==index?'act':'']"
  35. v-for="(item,index) in houseTypeList" :style="{'margin-right': index==1?'0':''}">
  36. {{item.value}}
  37. </view>
  38. </view>
  39. </view>
  40. <view class="bot">
  41. <view class="left">
  42. <view class="price">
  43. ¥{{totalPrice.toFixed(0)}}
  44. </view>
  45. <image src="/static/index/arrDown.png" mode=""></image>
  46. </view>
  47. <button open-type="share" v-if="orderSuc" class="right" :plain="true">
  48. 分享
  49. </button>
  50. <view class="right" v-else @click="confirmConfig">
  51. 确认配置
  52. </view>
  53. </view>
  54. <u-popup :show="showFixInfo" @close="close" @open="open" round='10'>
  55. <view class="topBar" style="">
  56. <view class="left">
  57. </view>
  58. <view class="cen">
  59. 信息填写
  60. </view>
  61. <view class="close" @click="showFixInfo=false">
  62. <u-icon name="close"></u-icon>
  63. </view>
  64. </view>
  65. <view class="pupopCon">
  66. <view class="item">
  67. <view class="label">
  68. 收货人
  69. </view>
  70. <u--input clearable placeholder="请输入收货人" border="surround" v-model="name"
  71. @change="change"></u--input>
  72. </view>
  73. <view class="item">
  74. <view class="label">
  75. 电话
  76. </view>
  77. <u--input clearable placeholder="请输入电话" border="surround" v-model="phone"
  78. @change="change"></u--input>
  79. </view>
  80. <view class="item" style="margin-bottom: 24rpx;height: auto;">
  81. <view class="label">
  82. 收货地址
  83. </view>
  84. <u--textarea v-model="addr" placeholder="请输入收货地址"></u--textarea>
  85. </view>
  86. <view class="item" style="margin-bottom: 64rpx;">
  87. <view class="label">
  88. 备注
  89. </view>
  90. <u--input clearable placeholder="请输入备注" border="surround" v-model="remark"
  91. @change="change"></u--input>
  92. </view>
  93. <button open-type="share" class="orderBtn" :plain="true">
  94. 确认下单
  95. </button>
  96. </view>
  97. </u-popup>
  98. </view>
  99. </template>
  100. <script>
  101. import {
  102. getIndexConfigReq,
  103. postOrderReq,
  104. } from '@/api/test/index.js'
  105. import {
  106. getDataMoneyReq
  107. } from '@/api/index/index.js'
  108. export default {
  109. components: {
  110. },
  111. data() {
  112. return {
  113. picUrl: this.$picUrl,
  114. picBase: this.$picBase,
  115. showFixInfo: false,
  116. addOrLessIcon1: '/static/index/shortLine.png',
  117. addOrLessIcon2: '/static/index/add.png',
  118. addOrLessIcon3: '/static/index/add.png',
  119. addOrLessIcon4: '/static/index/add.png',
  120. addOrLessIcon5: '/static/index/add.png',
  121. // lessIcon: require('/static/index/shortLine.png'),
  122. show1: true,
  123. show2: false,
  124. show3: false,
  125. show4: false,
  126. show5: false,
  127. currHouseIndex: -1,
  128. houseTypeList: [],
  129. selHx: null,
  130. totalPrice: 0,
  131. name: '',
  132. phone: '',
  133. addr: '',
  134. remark: '',
  135. orderId: '',
  136. pConfig: -1,
  137. orderSuc: false,
  138. cutdownRatio: 1,
  139. rule: '',
  140. topPic: ''
  141. }
  142. },
  143. async onLoad(options) {
  144. this.topPic = getApp().noMainImg.head_image
  145. console.log('4this.topPic', this.topPic);
  146. let res = await getIndexConfigReq({
  147. type: 4
  148. })
  149. if (res.code == 0) {
  150. console.log('获取首页配置返回值-全屋WiFi: ', res);
  151. this.houseTypeList = res.data.house_type
  152. // this.selHx = res.data.house_type[0]
  153. this.rule = res.data.rule.content
  154. // this.getPrice(4, this.selHx.id)
  155. }
  156. },
  157. onShow() {
  158. this.cutdownRatio = this.$getCutDown()
  159. },
  160. async onShareAppMessage(params) {
  161. if (params.from === 'button' || params.from === 'menu') {
  162. let phoneReg = /^[1][3,4,5,7,8,9][0-9]{9}$/
  163. // if (!this.name) {
  164. // return this.$toast('请填写收货人')
  165. // }
  166. // if (!this.phone) {
  167. // return this.$toast('请填写电话')
  168. // }
  169. // if (!phoneReg.test(this.phone)) {
  170. // return this.$toast('手机号格式不正确')
  171. // }
  172. // if (!this.addr) {
  173. // return this.$toast('请填写收货地址')
  174. // }
  175. // if (!this.remark) {
  176. // return this.$toast('请填写备注')
  177. // }
  178. if (this.phone && !phoneReg.test(this.phone)) {
  179. return this.$toast('手机号格式不正确')
  180. }
  181. let res = await postOrderReq({
  182. address: this.addr,
  183. phone: this.phone,
  184. name: this.name,
  185. remark: this.remark,
  186. config_id: this.pConfig,
  187. type: 4
  188. })
  189. if (res.code == 0) {
  190. console.log('提交订单返回值: ', res);
  191. this.orderId = res.data.orderId
  192. this.showFixInfo = false
  193. return {
  194. title: '定制我家的全屋WiFi',
  195. imageUrl: this.picBase + this.topPic,
  196. path: '/pages/index/fullHouseWifi_step2/index?orderId=' + this.orderId,
  197. mpId: this.$appId,
  198. type: this.$shareType,
  199. }
  200. } else {
  201. uni.showToast({
  202. title: res.message,
  203. icon: 'none'
  204. })
  205. }
  206. }
  207. },
  208. methods: {
  209. confirmConfig() {
  210. if (!this.selHx) {
  211. return this.$toast('请选择户型')
  212. }
  213. this.showFixInfo = true
  214. },
  215. toRule() {
  216. getApp().content = this.rule
  217. uni.navigateTo({
  218. url: '/pages/index/rule/index?type=wifi'
  219. })
  220. },
  221. async postOrder() {
  222. let res = await postOrderReq({
  223. address: this.addr,
  224. phone: this.phone,
  225. name: this.name,
  226. remark: this.remark,
  227. // config_id: String(this.selHx.id),
  228. config_id: this.pConfig,
  229. type: 4
  230. })
  231. if (res.code == 0) {
  232. console.log('提交订单返回值: ', res);
  233. this.$toast('提交成功')
  234. this.orderId = res.data.orderId
  235. this.showFixInfo = false
  236. this.orderSuc = true
  237. } else {
  238. uni.showToast({
  239. title: res.message,
  240. icon: 'none'
  241. })
  242. }
  243. },
  244. sel(item, index) {
  245. this.currHouseIndex = index
  246. this.selHx = item
  247. this.getPrice(4, this.selHx.id)
  248. },
  249. async getPrice(type = 4, house_type) {
  250. let res = await getDataMoneyReq({
  251. type,
  252. house_type,
  253. })
  254. if (res.code == 0) {
  255. console.log('配置价格-wifi: ', res)
  256. this.totalPrice = res.data.money * this.cutdownRatio
  257. this.pConfig = res.data.id
  258. } else {
  259. uni.showToast({
  260. title: res.message,
  261. icon: 'none'
  262. })
  263. }
  264. },
  265. handleOpenOrClose(i) {
  266. if (this['addOrLessIcon' + i] == '/static/index/shortLine.png') {
  267. this['addOrLessIcon' + i] = '/static/index/add.png'
  268. this['show' + i] = false
  269. } else if (this['addOrLessIcon' + i] == '/static/index/add.png') {
  270. this['addOrLessIcon' + i] = '/static/index/shortLine.png'
  271. this['show' + i] = true
  272. }
  273. },
  274. }
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  278. @import "./index.scss";
  279. </style>