index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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="picUrl + '/static/other/c2.png'" 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">
  66. <view class="con">
  67. <view class="top">
  68. <view class="item">
  69. <view class="name">
  70. 收货人
  71. </view>
  72. <view class="des">
  73. {{shareCon.name}}
  74. </view>
  75. </view>
  76. <view class="item">
  77. <view class="name">
  78. 电话
  79. </view>
  80. <view class="des">
  81. {{shareCon.phone}}
  82. </view>
  83. </view>
  84. <view class="item">
  85. <view class="name">
  86. 收货地址
  87. </view>
  88. <view class="des">
  89. {{shareCon.address}}
  90. </view>
  91. </view>
  92. <view class="item">
  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. <!-- <image v-if="!navBarTitle" @click="back" src="/static/index/backBtnImg.png" mode="" class="rule_img"></image> -->
  104. <view class="bot" v-if="!navBarTitle">
  105. <!-- <view class="left" @click="showPreviewConfig=true"> -->
  106. <view class="left" @click="">
  107. <view class="price">
  108. ¥{{totalPrice.toFixed(2)}}
  109. </view>
  110. <image v-if="!showPreviewConfig" src="/static/index/arrDown.png" mode=""
  111. @click="showPreviewConfig=true"></image>
  112. <image v-else src="/static/index/arrUp.png" mode="" @click="showPreviewConfig=false"></image>
  113. </view>
  114. <view class="right">
  115. <button open-type="share" v-if="orderSuc" class="btn" :plain="true">
  116. 分享
  117. </button>
  118. <view class="btn" v-else @click="showFixInfo=true">
  119. 确认配置
  120. </view>
  121. <view class="btn" v-if="!navBarTitle" @click="back" style="margin-left: 20rpx;">
  122. 返回
  123. </view>
  124. </view>
  125. </view>
  126. <u-popup :show="showFixInfo" @close="close" @open="open" round='10'>
  127. <view class="topBar" style="">
  128. <view class="left">
  129. </view>
  130. <view class="cen">
  131. 信息填写
  132. </view>
  133. <view class="close" @click="showFixInfo=false">
  134. <u-icon name="close"></u-icon>
  135. </view>
  136. </view>
  137. <view class="pupopCon">
  138. <view class="item">
  139. <view class="label">
  140. 收货人
  141. </view>
  142. <u--input clearable placeholder="请输入收货人" border="surround" v-model="name"
  143. @change="change"></u--input>
  144. </view>
  145. <view class="item">
  146. <view class="label">
  147. 电话
  148. </view>
  149. <u--input clearable placeholder="请输入电话" border="surround" v-model="phone"
  150. @change="change"></u--input>
  151. </view>
  152. <view class="item" style="margin-bottom: 24rpx;height: auto;">
  153. <view class="label">
  154. 收货地址
  155. </view>
  156. <u--textarea v-model="addr" placeholder="请输入收货地址"></u--textarea>
  157. </view>
  158. <view class="item" style="margin-bottom: 64rpx;">
  159. <view class="label">
  160. 备注
  161. </view>
  162. <u--input clearable placeholder="请输入备注" border="surround" v-model="remark"
  163. @change="change"></u--input>
  164. </view>
  165. <u-button text="确认下单" color="#333" @click="postOrder"></u-button>
  166. </view>
  167. </u-popup>
  168. </view>
  169. </template>
  170. <script>
  171. import {
  172. postOrderReq,
  173. getOrderDetailReq
  174. } from '@/api/test/index.js'
  175. export default {
  176. components: {
  177. },
  178. data() {
  179. return {
  180. picUrl: this.$picUrl,
  181. showFixInfo: false,
  182. showPreviewConfig: false,
  183. selHx: null,
  184. selPp: null,
  185. selSuo: null,
  186. selMb: null,
  187. selCl: null,
  188. selKt: null,
  189. totalPrice: null,
  190. name: '',
  191. phone: '',
  192. addr: '',
  193. remark: '',
  194. orderId: '',
  195. pConfig: -1,
  196. shareCon: null,
  197. navBarTitle: '',
  198. orderSuc: false,
  199. }
  200. },
  201. async onLoad(o) {
  202. // o.orderId = '43c43ced14b312fb69d80cedbd7b23f4'
  203. if (o.orderId) {
  204. this.orderId = o.orderId
  205. this.navBarTitle = '首页'
  206. console.log('o.orderId', o.orderId);
  207. let res = await getOrderDetailReq({
  208. orderId: o.orderId
  209. })
  210. if (res.code == 0) {
  211. console.log('邀请订单详情返回值-智能控制系统: ', res);
  212. this.shareCon = res.data
  213. this.selHx = res.data.config.house_type_data
  214. this.selPp = res.data.config.brand
  215. this.selSuo = res.data.config.mind_lock
  216. this.selMb = res.data.config.mind_switch
  217. this.selCl = res.data.config.mind_curtain
  218. this.selKt = res.data.config.mind_air_conditioner
  219. } else {
  220. uni.showToast({
  221. title: res.message,
  222. icon: 'none'
  223. })
  224. }
  225. } else {
  226. this.selHx = getApp().selHx
  227. this.selPp = getApp().selPp
  228. this.selSuo = getApp().selSuo
  229. this.selMb = getApp().selMb
  230. this.selCl = getApp().selCl
  231. this.selKt = getApp().selKt
  232. this.totalPrice = getApp().totalPrice
  233. this.pConfig = getApp().pConfig
  234. }
  235. },
  236. onShareAppMessage(params) {
  237. if (params.from === 'button' || params.from === 'menu') {
  238. return {
  239. title: '定制我家的智能控制系统',
  240. imageUrl: this.picUrl + '/static/other/c2.png',
  241. path: '/pages/index/aiControlSys_step2/index?orderId=' + this.orderId,
  242. mpId: this.$appId,
  243. type: this.$shareType,
  244. }
  245. }
  246. },
  247. methods: {
  248. async postOrder() {
  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. console.log('智控下单参数', {
  266. address: this.addr,
  267. phone: this.phone,
  268. name: this.name,
  269. remark: this.remark,
  270. config_id: this.selHx.id + ',' + this.selPp.id + ',' + this.selSuo.id + ',' + this.selMb
  271. .id + ',' + this.selCl.id + ',' + this.selKt.id,
  272. type: 3
  273. });
  274. let res = await postOrderReq({
  275. address: this.addr,
  276. phone: this.phone,
  277. name: this.name,
  278. remark: this.remark,
  279. // config_id: this.selHx.id + ',' + this.selPp.id + ',' + this.selSuo.id + ',' + this.selMb
  280. // .id + ',' + this.selCl.id + ',' + this.selKt.id,
  281. config_id: this.pConfig,
  282. type: 3
  283. })
  284. if (res.code == 0) {
  285. console.log('提交订单返回值: ', res);
  286. this.$toast('提交成功')
  287. this.orderId = res.data.orderId
  288. this.showFixInfo = false
  289. this.orderSuc = true
  290. } else {
  291. uni.showToast({
  292. title: res.message,
  293. icon: 'none'
  294. })
  295. }
  296. },
  297. back() {
  298. uni.navigateBack()
  299. }
  300. }
  301. }
  302. </script>
  303. <style lang="scss" scoped>
  304. @import "./index.scss";
  305. </style>