yuyue.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <view class="content">
  3. <view class="content-form">
  4. <view class="content-detail">
  5. <view class="detail-text">
  6. <u-image src="/static/pop_icon_warning.png" width="32" height="32"></u-image>
  7. <text>请按照回收要求合理预约服务</text>
  8. </view>
  9. <view class="detail-xqtext">查看详情</view>
  10. </view>
  11. <view class="form-data">
  12. <u-form :model="form" ref="uForm" :label-width="140" :error-type="['toast']">
  13. <u-form-item prop="time" label="预约时间:" required>
  14. <u-select v-model="show" mode="mutil-column-auto" :list="list" @confirm="confirm"></u-select>
  15. <u-input placeholder="请选择预约时间" v-model="time" @click="selectTime" :disabled="true"/>
  16. <u-icon name="arrow-right" slot="right" @click="selectTime"></u-icon>
  17. </u-form-item>
  18. <u-form-item prop="info" label="用户信息:" required>
  19. <u-input placeholder="请选择用户信息" v-model="form.info" @click="selectUserInfo" :disabled="true"/>
  20. <u-icon name="arrow-right" slot="right" @click="selectUserInfo"></u-icon>
  21. </u-form-item>
  22. </u-form>
  23. </view>
  24. <view class="form-data rubbishType">
  25. <view class="rubbishType-title u-required:before">回收分类</view>
  26. <view class="rubbishType-tags">
  27. <view :class="['item-tags', item.check ? 'active' : '']" v-for="item in rubbishTypeListData" :key="item.code" @click="itemRubbishChange(item)">{{item.dispName}}</view>
  28. </view>
  29. </view>
  30. <view class="form-data rubbishType">
  31. <view class="rubbishType-title u-required:before">预估重量</view>
  32. <view class="rubbishType-tags">
  33. <view :class="['item-weightTags', checkWeightType == item.code ? 'active' : '']" v-for="item in rubbishweightList" :key="item.code" @click="itemRubbishWeightChange(item)">{{item.dispName}}</view>
  34. </view>
  35. </view>
  36. <view class="form-data qyImg">
  37. <view> 上传图片 <text style="color: #a6a6a6;">(最多3张,单张10MB以内)</text></view>
  38. <view class="info-main">
  39. <view v-if="photograph.length<3 && !isView" class="camera-btn">
  40. <view @click="goPhotograph" class="photograph-camera">
  41. <u-icon name="camera" color="#bfbfbf" size="60" ></u-icon>
  42. </view>
  43. </view>
  44. <view v-show="photograph.length" v-for="(item,index) in photograph" :key="index" class="photograph-con">
  45. <u-icon v-show="!isView" name="close-circle-fill" color="#fa3534" size="50" class="close-circle-icon" @click="cancelPhotograph(index)"></u-icon>
  46. <u-image width="100%" height="100%" :src="item" @click="previewPictures(item)"></u-image>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view style="color:#FF2C5C;text-align: center;margin-bottom: 10upx;" v-if="!hasRider">当前地址/时段无可上门骑手,暂不能下单</view>
  52. <view class="btns">
  53. <!-- <u-button @click="submit" :loading="loading" :custom-style="submitBtn" :disabled="!hasRider">提交</u-button> -->
  54. <u-button @click="submit" :loading="loading" :custom-style="submitBtn">提交</u-button>
  55. </view>
  56. <!-- <uni-popup ref="openModal" type="center">
  57. <uni-popup-dialog content="确认提交吗?" @confirm="onOk" :title="title"></uni-popup-dialog>
  58. </uni-popup> -->
  59. </view>
  60. </template>
  61. <script>
  62. // import uniPopup from '@/components/uni-popup/uni-popup.vue'
  63. // import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
  64. import {gatherSave,gatherDetail,searchRider} from '@/api/index.js'
  65. import {saveImgToAliOss} from '@/libs/tools.js'
  66. import { getLookUpDatas,userDetail,yuyueInfoSave } from '@/api/data'
  67. export default {
  68. // components: {
  69. // uniPopup,uniPopupDialog
  70. // },
  71. data() {
  72. return {
  73. title:'',
  74. loading:false, // 提交按钮加载圈
  75. check:'', // 是否选中
  76. checkWeightType:'',
  77. photograph: [], // 图片路径
  78. RubbishType:[], // 回收分类
  79. rubbishweightList:[], // 重量分类
  80. weightType:'',
  81. weightTagType:'info', // 重量按钮类型
  82. latitude:'', // 当前位置经度
  83. longitude:'' ,// 当前位置维度
  84. day:'', // 今天、明天,后天
  85. timeType:'', // 上午、下午
  86. time: '', // 其它垃圾
  87. rubbishTypeListData:[],
  88. userDetailInfo:{}, // 用户信息
  89. nowDate:null,
  90. form: {
  91. info: '', // 厨余垃圾
  92. },
  93. rubbishTypeList:[], // 垃圾类型
  94. reserveWeight:'',
  95. isView: false ,// 是否是查看详情
  96. hasRider:true, // 是否有骑手
  97. itemId:'',
  98. submitBtn:{
  99. backgroundColor: '#4F88F7',
  100. color: '#fff',
  101. borderRadius: '12px'
  102. },
  103. show: false,
  104. list: [
  105. {
  106. value: 1,
  107. label: '今天',
  108. children: [
  109. {
  110. value: 2,
  111. label: '上午(08-13点)',
  112. },
  113. {
  114. value: 3,
  115. label: '下午(13-18点)',
  116. }
  117. ]
  118. },
  119. {
  120. value: 4,
  121. label: '明天',
  122. children: [
  123. {
  124. value: 5,
  125. label: '上午(08-13点)',
  126. },
  127. {
  128. value: 6,
  129. label: '下午(13-18点)',
  130. }
  131. ]
  132. },
  133. {
  134. value: 7,
  135. label: '后天',
  136. children: [
  137. {
  138. value: 8,
  139. label: '上午(08-13点)',
  140. },
  141. {
  142. value: 9,
  143. label: '下午(13-18点)',
  144. }
  145. ]
  146. },
  147. ],
  148. // rules: {
  149. // time: [
  150. // {
  151. // required: true,
  152. // message: '请选择时间',
  153. // trigger: ['blur', 'change']
  154. // }
  155. // ],
  156. // info:[{required:true,message:'请选择用户信息',trigger:['change']}]
  157. // }
  158. };
  159. },
  160. onLoad(option) {
  161. console.log(option,option.id,'ppppppppp')
  162. this.rubbishType()
  163. this.getDetailData()
  164. this.rubbishWeightType()
  165. const date=new Date
  166. const year=date.getFullYear()
  167. const month = date.getMonth() + 1
  168. const day = date.getDate()
  169. this.nowDate = year + "-" +( month<10? '0'+month:month ) + "-" + (day<10? '0'+day:day);
  170. console.log(date.getFullYear(),nowDate,date.getMonth(),'-----------日期')
  171. // 查看
  172. if(option && option.id){
  173. this.isView = true
  174. this.itemId=option.id
  175. }else {
  176. console.log('--------新增')
  177. this.photograph = []
  178. this.form.remarks = ''
  179. this.$refs.uForm.resetFields()
  180. }
  181. wx.getLocation({
  182. type: 'wgs84',
  183. success:(res=> {
  184. if(res.latitude && res.longitude){
  185. this.latitude = res.latitude
  186. this.longitude = res.longitude
  187. }
  188. console.log(res,'位置信息',this.latitude,this.longitude)
  189. })
  190. })
  191. setTimeout(()=>{
  192. this.getRiderStatus()
  193. },300)
  194. },
  195. onUnload() {
  196. },
  197. watch:{
  198. },
  199. methods: {
  200. // 获取垃圾分类
  201. rubbishType () {
  202. let _this = this
  203. getLookUpDatas({
  204. type: 'RESERVE_RUBBISH_TYPE'
  205. }).then(result => {
  206. if (result && result.status + '' === '200') {
  207. result.data.forEach(item=>{
  208. item.check=false
  209. })
  210. this.$nextTick(()=>{
  211. _this.rubbishTypeListData= result.data || []
  212. console.log(_this.rubbishTypeListData,'_this.rubbishTypeListData','---------------------')
  213. })
  214. }
  215. })
  216. },
  217. rubbishWeightType () {
  218. let _this = this
  219. getLookUpDatas({
  220. type: 'RUBBISH_WEIGHT_TEMPLATE'
  221. }).then(result => {
  222. if (result && result.status + '' === '200') {
  223. _this.rubbishweightList= result.data || []
  224. }
  225. })
  226. },
  227. // 查询附近有无骑手可接单
  228. getRiderStatus(){
  229. searchRider({lng:this.longitude,lat:this.latitude}).then(res=>{
  230. if(res.status==200){
  231. this.hasRider=res.data
  232. }
  233. console.log(res,'-----------')
  234. })
  235. },
  236. // 选择时间
  237. selectTime(){
  238. wx.hideKeyboard()
  239. this.show=true
  240. },
  241. confirm(e) {
  242. if(e){
  243. this.time=e[0].label + e[1].label
  244. this.day=e[0].label
  245. // if(e[0].label=='今天'){
  246. // this.day
  247. // }
  248. this.timeType=e[1].label.substr(0, e[1].label.indexOf("(")) // 上午、下午
  249. console.log(e,'----------时间',this.day,this.timeType,e[1].label)
  250. }
  251. },
  252. // 选择用户信息
  253. selectUserInfo(){
  254. uni.navigateTo({
  255. url: '/pages/index/userInfo'
  256. })
  257. },
  258. // 选择垃圾分类
  259. itemRubbishChange(item){
  260. item.check=!item.check
  261. // this.rubbishTypeList.push(item.code)
  262. console.log(item,item.code,'--------------',this.check)
  263. },
  264. itemRubbishWeightChange(item){
  265. this.checkWeightType=item.code
  266. this.reserveWeight=item.code
  267. console.log(item,item.code,'--------------',this.check)
  268. },
  269. // 选择重量
  270. chooseWeight(value){
  271. console.log('-------选中重量')
  272. },
  273. // 获取详情数据
  274. getDetailData(){
  275. userDetail().then(res=>{
  276. if(res.status==200){
  277. this.form.info=res.data.contactName
  278. this.userDetailInfo=res.data
  279. console.log(res)
  280. }
  281. })
  282. },
  283. // 拍照或从相册选图片
  284. goPhotograph() {
  285. uni.chooseImage({
  286. count: 1, //默认9
  287. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  288. sourceType: ['album','camera'], //从相册选择
  289. success: (res) =>{
  290. console.log(res,'rrrrrrrrrrr')
  291. console.log(JSON.stringify(res.tempFilePaths));
  292. console.log(this.photograph.length,'this.photograph')
  293. if(res.tempFiles[0].size>10485760){
  294. uni.showToast({
  295. title: '图片过大无法上传!',
  296. icon: 'none'
  297. })
  298. return
  299. }
  300. uni.showLoading({
  301. title:'正在保存图片...',
  302. mask: true
  303. })
  304. saveImgToAliOss(res.tempFilePaths[0],(ret)=>{
  305. this.photograph.push(ret.data)
  306. uni.hideLoading()
  307. })
  308. }
  309. });
  310. },
  311. // 预览图片
  312. previewPictures(item) {
  313. const photograph = [item];
  314. uni.previewImage({
  315. urls: photograph,
  316. });
  317. },
  318. // 删除图片
  319. cancelPhotograph(index) {
  320. setTimeout(() => {
  321. this.photograph.splice(index,1)
  322. }, 500);
  323. },
  324. // 提交
  325. submit(){
  326. this.$refs.uForm.validate(valid => {
  327. const params= Object.assign(this.userDetailInfo, this.form)
  328. if(this.time){
  329. params.dayStr=this.day
  330. params.reserveTimeType=this.timeType
  331. if(params.reserveTimeType=='上午'){
  332. params.beginStr='08:00:00', // 预约开始时间
  333. params.endStr="12:59:59"
  334. }else{
  335. params.beginStr='13:00:00', // 预约开始时间
  336. params.endStr="18:00:00"
  337. }
  338. }
  339. if(this.rubbishTypeList){
  340. params.rubbishTypeList=this.rubbishTypeList
  341. }
  342. if(this.reserveWeight){
  343. params.reserveWeight=this.reserveWeight
  344. }
  345. console.log(params,'--------------参数')
  346. if (valid) {
  347. console.log('验证通过');
  348. yuyueInfoSave(params).then(res=>{
  349. if(res.status==200){
  350. uni.showToast({
  351. title: res.message,
  352. icon: 'none'
  353. })
  354. setTimeout(()=>{
  355. uni.navigateTo({
  356. url: '/pages/index/yuyueResult'
  357. })
  358. },500)
  359. }
  360. })
  361. } else {
  362. console.log('验证失败');
  363. }
  364. });
  365. },
  366. // 确认提交
  367. // onOk() {
  368. // this.$refs.openModal.close()
  369. // let params = {
  370. // rubbishEntityList: [],
  371. // imageUrlList: this.photograph,
  372. // remarks: this.form.remarks
  373. // }
  374. // if(this.itemId){
  375. // params.id=this.itemId
  376. // }
  377. // if(this.form.gatherNum_other) {
  378. // params.rubbishEntityList.push({
  379. // "rubbishType":"GATHER_OTHER",
  380. // "rubbishWeight": this.form.gatherNum_other*240,
  381. // "gatherNum": this.form.gatherNum_other,
  382. // "unit":"BUCKET"
  383. // })
  384. // }
  385. // if(this.form.gatherNum_chuyu) {
  386. // params.rubbishEntityList.push({
  387. // "rubbishType":"GATHER_KITCHEN",
  388. // "rubbishWeight": this.form.gatherNum_chuyu*240,
  389. // "gatherNum": this.form.gatherNum_chuyu,
  390. // "unit":"BUCKET"
  391. // })
  392. // }
  393. // if(this.form.gatherNum_jianzhu) {
  394. // params.rubbishEntityList.push({
  395. // "rubbishType":"GATHER_BUILDING",
  396. // "rubbishWeight": this.form.gatherNum_jianzhu*1000,
  397. // "gatherNum": this.form.gatherNum_jianzhu,
  398. // "unit":"TON"
  399. // })
  400. // }
  401. // this.loading=true
  402. // gatherSave(params).then(res=>{
  403. // if(res.status == 200) {
  404. // uni.showToast({
  405. // title: res.message,
  406. // icon: 'none'
  407. // })
  408. // setTimeout(()=>{
  409. // uni.navigateBack()
  410. // },300)
  411. // } else {
  412. // uni.showToast({
  413. // title: res.message,
  414. // icon: 'none'
  415. // })
  416. // }
  417. // this.loading= false
  418. // })
  419. // },
  420. },
  421. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  422. onReady() {
  423. this.$refs.uForm.setRules(this.rules);
  424. }
  425. }
  426. </script>
  427. <style lang="scss">
  428. .content{
  429. width: 100%;
  430. height: 100vh;
  431. padding: 0;
  432. background: #F5F5F5;
  433. display: flex;
  434. flex-direction: column;
  435. .content-form{
  436. flex: 1;
  437. overflow-y: scroll;
  438. .content-detail{
  439. padding:20upx 30upx;
  440. background: rgba(255, 209, 0, 0.4);
  441. opacity: 1;
  442. display: flex;
  443. justify-content: space-between;
  444. .detail-text{
  445. display: flex;
  446. align-items: center;
  447. text{
  448. display: inline-block;
  449. margin-left: 15upx;
  450. }
  451. }
  452. .detail-xqtext{
  453. font-size: 30upx;
  454. font-family: PingFang SC;
  455. font-weight: 500;
  456. color: #FF9528;
  457. }
  458. }
  459. }
  460. .receiveAddress{
  461. width: 100%;
  462. line-height: 1.5em;
  463. box-sizing: border-box;
  464. font-style: normal;
  465. }
  466. .form-data{
  467. padding:0 30upx 0 50upx;
  468. margin-bottom: 20upx;
  469. background-color: #fff;
  470. }
  471. .rubbishType{
  472. padding:30upx 30upx 30upx 50upx;
  473. .rubbishType-title{
  474. margin-bottom: 20upx;
  475. }
  476. .rubbishType-tags{
  477. display: flex;
  478. justify-content: space-between;
  479. .item-tags.active{
  480. padding: 10upx;
  481. background-color:rgba(79, 136, 247, 0.2);
  482. border-radius: 100px;
  483. }
  484. .item-weightTags.active{
  485. padding: 10upx;
  486. background-color:rgba(79, 136, 247, 0.2);
  487. border-radius: 100px;
  488. }
  489. .check{
  490. background: #F5F5F5;
  491. }
  492. }
  493. }
  494. .qyImg{
  495. padding: 40upx ;
  496. }
  497. .info-main {
  498. margin-top: 14upx;
  499. border-radius: 12upx;
  500. background-color: #fff;
  501. display: flex;
  502. .location-icon {
  503. padding-left: 10upx;
  504. vertical-align: sub;
  505. }
  506. .photograph-camera {
  507. border: 2upx dashed #bfbfbf;
  508. border-radius: 12upx;
  509. width: 140upx;
  510. height: 140upx;
  511. display: flex;
  512. align-items: center;
  513. justify-content: center;
  514. }
  515. .camera-btn{
  516. display: flex;
  517. flex-direction: column;
  518. align-items: center;
  519. color: #999999;
  520. font-size: 24upx;
  521. }
  522. .photograph-con {
  523. margin: 0 20upx;
  524. width: 140upx;
  525. height: 140upx;
  526. text-align: center;
  527. position: relative;
  528. .photograph-icon {
  529. display: inline-block;
  530. padding-top: 48upx;
  531. }
  532. .close-circle-icon {
  533. background-color: #fff;
  534. border-radius: 50%;
  535. position: absolute;
  536. right: -23upx;
  537. top: -23upx;
  538. z-index: 9;
  539. }
  540. }
  541. }
  542. .btns{
  543. padding: 30upx 30upx 50upx;
  544. background-color: #fff;
  545. }
  546. }
  547. </style>