index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <view class="page">
  3. <navBar :backType="navBarTitle" :title="navBarTitle?navBarTitle:'智能控制系统'" :back="true" color="black"
  4. background="white" />
  5. <image class="topImg" :src="picBase + topPic" mode=""></image>
  6. <view class="cen">
  7. <image class="water" src="/static/index/water.png" mode=""></image>
  8. <image class="halfC" src="/static/index/halfCircle_275.png" mode=""></image>
  9. 定制我家的智能控制系统
  10. </view>
  11. <view class="parmasBox">
  12. <view class="con">
  13. <view class="top">
  14. <view class="item">
  15. <view class="name">
  16. 户型
  17. </view>
  18. <view class="des">
  19. {{selHx.value}}
  20. </view>
  21. </view>
  22. <view class="item">
  23. <view class="name">
  24. 品牌
  25. </view>
  26. <view class="des">
  27. {{selPp.value}}
  28. </view>
  29. </view>
  30. <view class="item">
  31. <view class="name">
  32. 智能锁
  33. </view>
  34. <view class="des">
  35. {{selSuo.value}}
  36. </view>
  37. </view>
  38. <view class="item">
  39. <view class="name">
  40. 智能开关
  41. </view>
  42. <view class="des">
  43. {{selMb.value}}
  44. </view>
  45. </view>
  46. <view class="item">
  47. <view class="name">
  48. 智能窗帘
  49. </view>
  50. <view class="des">
  51. {{selCl.value}}
  52. </view>
  53. </view>
  54. <view class="item">
  55. <view class="name">
  56. 智能空调
  57. </view>
  58. <view class="des">
  59. {{selKt.value}}
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="parmasBox" v-if="navBarTitle&&(shareCon.name||shareCon.phone||shareCon.address||shareCon.remark)">
  66. <view class="con">
  67. <view class="top">
  68. <view class="item" v-if="shareCon.name">
  69. <view class="name">
  70. 收货人
  71. </view>
  72. <view class="des">
  73. {{shareCon.name}}
  74. </view>
  75. </view>
  76. <view class="item" v-if="shareCon.phone">
  77. <view class="name">
  78. 电话
  79. </view>
  80. <view class="des">
  81. {{shareCon.phone}}
  82. </view>
  83. </view>
  84. <view class="item" v-if="shareCon.address">
  85. <view class="name">
  86. 收货地址
  87. </view>
  88. <view class="des">
  89. {{shareCon.address}}
  90. </view>
  91. </view>
  92. <view class="item" v-if="shareCon.remark">
  93. <view class="name">
  94. 备注
  95. </view>
  96. <view class="des">
  97. {{shareCon.remark}}
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. <view class="bot" v-if="!navBarTitle">
  104. <view class="left">
  105. <view class="price">
  106. ¥{{totalPrice.toFixed(0)}}
  107. </view>
  108. <image v-if="!showPreviewConfig" src="/static/index/arrDown.png" mode=""
  109. @click="showPreviewConfig=true"></image>
  110. <image v-else src="/static/index/arrUp.png" mode="" @click="showPreviewConfig=false"></image>
  111. </view>
  112. <view class="right">
  113. <view class="btn" @click.stop="openInfoBox">
  114. 确认配置
  115. </view>
  116. <view class="btn" v-if="!navBarTitle" @click="back" style="margin-left: 20rpx;">
  117. 返回
  118. </view>
  119. </view>
  120. </view>
  121. <u-popup :show="showFixInfo" @close="" @open="" round='10'>
  122. <view class="topBar" style="">
  123. <view class="left">
  124. </view>
  125. <view class="cen">
  126. 信息填写
  127. </view>
  128. <view class="close" @click="closeInfoBox">
  129. <u-icon name="close"></u-icon>
  130. </view>
  131. </view>
  132. <view class="pupopCon">
  133. <view class="item">
  134. <view class="label">
  135. 收货人
  136. </view>
  137. <u--input clearable placeholder="请输入收货人" border="surround" v-model="name"
  138. @change="change"></u--input>
  139. </view>
  140. <view class="item">
  141. <view class="label">
  142. 电话
  143. </view>
  144. <u--input clearable placeholder="请输入电话" border="surround" v-model="phone"
  145. @change="change"></u--input>
  146. </view>
  147. <view class="item" style="margin-bottom: 24rpx;height: auto;">
  148. <view class="label">
  149. 收货地址
  150. </view>
  151. <u--textarea v-model="addr" placeholder="请输入收货地址"></u--textarea>
  152. </view>
  153. <view class="item" style="margin-bottom: 64rpx;">
  154. <view class="label">
  155. 备注
  156. </view>
  157. <u--input clearable placeholder="请输入备注" border="surround" v-model="remark"
  158. @change="change"></u--input>
  159. </view>
  160. <button open-type="share" class="orderBtn" :plain="true">
  161. 确认下单
  162. </button>
  163. </view>
  164. </u-popup>
  165. </view>
  166. </template>
  167. <script>
  168. import {
  169. postOrderReq,
  170. getOrderDetailReq
  171. } from '@/api/test/index.js'
  172. import {
  173. getBannerDataReq,
  174. } from '@/api/index/index.js'
  175. export default {
  176. components: {
  177. },
  178. data() {
  179. return {
  180. picUrl: this.$picUrl,
  181. picBase: this.$picBase,
  182. topPic: '',
  183. showFixInfo: false,
  184. showPreviewConfig: false,
  185. selHx: null,
  186. selPp: null,
  187. selSuo: null,
  188. selMb: null,
  189. selCl: null,
  190. selKt: null,
  191. totalPrice: null,
  192. name: '',
  193. phone: '',
  194. addr: '',
  195. remark: '',
  196. orderId: '',
  197. pConfig: -1,
  198. shareCon: null,
  199. navBarTitle: '',
  200. orderSuc: false,
  201. }
  202. },
  203. async onLoad(o) {
  204. let res11 = await getBannerDataReq()
  205. if (res11.code == 0) {
  206. console.log('1-----图片配置数据', res11);
  207. this.topPic = res11.data.find((item, index) => {
  208. return item.title == '智能控制系统'
  209. }).head_image
  210. } else {
  211. this.$toast(res11.message)
  212. }
  213. // o.orderId = 'f0b8c1bb32008715f63d1dfd8876c50f'
  214. if (o.orderId) {
  215. this.orderId = o.orderId
  216. this.navBarTitle = '首页'
  217. console.log('o.orderId', o.orderId);
  218. let res = await getOrderDetailReq({
  219. orderId: o.orderId
  220. })
  221. if (res.code == 0) {
  222. console.log('邀请订单详情返回值-智能控制系统: ', res);
  223. this.shareCon = res.data
  224. this.selHx = res.data.config.house_type_data
  225. this.selPp = res.data.config.brand_data
  226. this.selSuo = res.data.config.mind_lock_data
  227. this.selMb = res.data.config.mind_switch_data
  228. this.selCl = res.data.config.mind_curtain_data
  229. this.selKt = res.data.config.mind_air_conditioner_data
  230. } else {
  231. uni.showToast({
  232. title: res.message,
  233. icon: 'none'
  234. })
  235. }
  236. } else {
  237. this.selHx = getApp().selHx
  238. this.selPp = getApp().selPp
  239. this.selSuo = getApp().selSuo
  240. this.selMb = getApp().selMb
  241. this.selCl = getApp().selCl
  242. this.selKt = getApp().selKt
  243. this.totalPrice = getApp().totalPrice
  244. this.pConfig = getApp().pConfig
  245. }
  246. },
  247. async onShareAppMessage(params) {
  248. if (params.from === 'button' || params.from === 'menu') {
  249. let phoneReg = /^[1][3,4,5,7,8,9][0-9]{9}$/
  250. // if (!this.name) {
  251. // return this.$toast('请填写收货人')
  252. // }
  253. // if (!this.phone) {
  254. // return this.$toast('请填写电话')
  255. // }
  256. // if (!phoneReg.test(this.phone)) {
  257. // return this.$toast('手机号格式不正确')
  258. // }
  259. // if (!this.addr) {
  260. // return this.$toast('请填写收货地址')
  261. // }
  262. // if (!this.remark) {
  263. // return this.$toast('请填写备注')
  264. // }
  265. if (this.phone && !phoneReg.test(this.phone)) {
  266. return this.$toast('手机号格式不正确')
  267. }
  268. let res = await postOrderReq({
  269. address: this.addr,
  270. phone: this.phone,
  271. name: this.name,
  272. remark: this.remark,
  273. config_id: this.pConfig,
  274. type: 3
  275. })
  276. if (res.code == 0) {
  277. console.log('提交订单返回值: ', res);
  278. this.orderId = res.data.orderId
  279. this.showFixInfo = false
  280. return {
  281. title: '定制我家的智能控制系统',
  282. imageUrl: this.picBase + this.topPic,
  283. path: '/pages/index/aiControlSys_step2/index?orderId=' + this.orderId,
  284. mpId: this.$appId,
  285. type: this.$shareType,
  286. }
  287. } else {
  288. uni.showToast({
  289. title: res.message,
  290. icon: 'none'
  291. })
  292. }
  293. }
  294. },
  295. methods: {
  296. openInfoBox() {
  297. this.showFixInfo = true
  298. },
  299. closeInfoBox() {
  300. this.showFixInfo = false
  301. },
  302. async postOrder() {
  303. let phoneReg = /^[1][3,4,5,7,8,9][0-9]{9}$/
  304. if (!this.name) {
  305. return this.$toast('请填写收货人')
  306. }
  307. if (!this.phone) {
  308. return this.$toast('请填写电话')
  309. }
  310. if (!phoneReg.test(this.phone)) {
  311. return this.$toast('手机号格式不正确')
  312. }
  313. if (!this.addr) {
  314. return this.$toast('请填写收货地址')
  315. }
  316. if (!this.remark) {
  317. return this.$toast('请填写备注')
  318. }
  319. console.log('智控下单参数', {
  320. address: this.addr,
  321. phone: this.phone,
  322. name: this.name,
  323. remark: this.remark,
  324. config_id: this.selHx.id + ',' + this.selPp.id + ',' + this.selSuo.id + ',' + this.selMb
  325. .id + ',' + this.selCl.id + ',' + this.selKt.id,
  326. type: 3
  327. });
  328. let res = await postOrderReq({
  329. address: this.addr,
  330. phone: this.phone,
  331. name: this.name,
  332. remark: this.remark,
  333. // config_id: this.selHx.id + ',' + this.selPp.id + ',' + this.selSuo.id + ',' + this.selMb
  334. // .id + ',' + this.selCl.id + ',' + this.selKt.id,
  335. config_id: this.pConfig,
  336. type: 3
  337. })
  338. if (res.code == 0) {
  339. console.log('提交订单返回值: ', res);
  340. this.$toast('提交成功')
  341. this.orderId = res.data.orderId
  342. this.showFixInfo = false
  343. this.orderSuc = true
  344. } else {
  345. uni.showToast({
  346. title: res.message,
  347. icon: 'none'
  348. })
  349. }
  350. },
  351. back() {
  352. uni.navigateBack()
  353. }
  354. }
  355. }
  356. </script>
  357. <style lang="scss" scoped>
  358. @import "./index.scss";
  359. </style>