myPile.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <template>
  2. <view>
  3. <ujp-navbar title="充电桩设置"></ujp-navbar>
  4. <view class="options">
  5. <u-cell-group>
  6. <u-cell-item title="开放共享" :arrow="false">
  7. <view class="" >
  8. <u-radio-group v-model="detail.enableShare" >
  9. <u-radio v-for="(item, index) in list2" :key="index+'a'" :name="item.value"
  10. :disabled="item.disabled" active-color="#00b962">
  11. {{item.name}}
  12. </u-radio>
  13. </u-radio-group>
  14. </view>
  15. </u-cell-item>
  16. <u-cell-item title="开放预约" :arrow="false">
  17. <view class="">
  18. <u-radio-group v-model="detail.enableAppointment" >
  19. <u-radio v-for="(item, index) in list2" :key="index+'b'" :name="item.value"
  20. :disabled="item.disabled" active-color="#00b962">
  21. {{item.name}}
  22. </u-radio>
  23. </u-radio-group>
  24. </view>
  25. </u-cell-item>
  26. <u-cell-item title="预约自动确认" :arrow="false">
  27. <view class="">
  28. <u-radio-group v-model="detail.autoConfirm" >
  29. <u-radio v-for="(item, index) in list2" :key="index+'c'" :name="item.value"
  30. active-color="#00b962">
  31. {{item.name}}
  32. </u-radio>
  33. </u-radio-group>
  34. </view>
  35. </u-cell-item>
  36. <u-cell-item :arrow="false" class="time-cell border-bottom" title="允许预约日期">
  37. </u-cell-item>
  38. <view class="" style="padding-left: 16px;">
  39. <u-checkbox-group shape="square">
  40. <u-checkbox
  41. v-for="(item, index) in weekList" :key="index" :name="item.value"
  42. v-model="item.checked" @change="checkboxChange(item,$event)"
  43. :disabled="item.disabled" active-color="#00b962">
  44. {{item.name}}
  45. </u-checkbox>
  46. </u-checkbox-group>
  47. </view>
  48. <u-picker mode="time" @confirm="confirm" v-model="show"
  49. :defaultTime="showTime"
  50. :params="params"></u-picker>
  51. <u-cell-item title="预约开始时段" :value="detail.shareStartTime" @click="showTimeBtn(0)" ></u-cell-item>
  52. <u-cell-item title="预约结束时段" :value="detail.shareEndTime" @click="showTimeBtn(1)" ></u-cell-item>
  53. <u-cell-item :arrow="false" class="time-cell border-bottom" title="预约时长选项">
  54. </u-cell-item>
  55. <view class="" style="padding-left: 16px;">
  56. <u-checkbox-group shape="square">
  57. <u-checkbox v-for="(item, index) in timeList"
  58. v-model="item.checked" @change="checkboxChange(item,$event)"
  59. :key="index" :name="item.value"
  60. :disabled="item.disabled" active-color="#00b962">
  61. {{item.name}}
  62. </u-checkbox>
  63. </u-checkbox-group>
  64. </view>
  65. </u-cell-group>
  66. </view>
  67. <!-- 底部按钮 -->
  68. <view class="bottom">
  69. <!-- <u-button shape='circle' class="refuse-btn">拒绝</u-button>
  70. <u-button type="success" shape='circle'>确认</u-button> -->
  71. <!-- 删除订单按钮 -->
  72. <u-button shape='circle' type="success" @click="submit" >保存</u-button>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. import * as API from '@/apis/finance.js'
  78. export default {
  79. data() {
  80. return {
  81. showTimeType:"",
  82. showTime:"",
  83. show:false,
  84. params: {
  85. year: false,
  86. month: false,
  87. day: false,
  88. hour: true,
  89. minute: true,
  90. second: false
  91. },
  92. detail:{
  93. },
  94. list2: [{
  95. value:"1",
  96. name: "是"
  97. },
  98. {
  99. value:"0",
  100. name: "否"
  101. }
  102. ],
  103. weekList: [
  104. {
  105. value:"1",
  106. name: "周一"
  107. },
  108. {
  109. value:"2",
  110. name: "周二"
  111. },
  112. {
  113. value:"3",
  114. name: "周三"
  115. },
  116. {
  117. value:"4",
  118. name: "周四"
  119. },
  120. {
  121. value:"5",
  122. name: "周五"
  123. },
  124. {
  125. value:"6",
  126. name: "周六"
  127. },
  128. {
  129. value:"7",
  130. name: "周日"
  131. }
  132. ],
  133. timeList: [
  134. {
  135. value:"10",
  136. name: "10分钟"
  137. },
  138. {
  139. value:"20",
  140. name: "20分钟"
  141. },
  142. {
  143. value:"30",
  144. name: "30分钟"
  145. }
  146. ]
  147. }
  148. },
  149. onLoad(op){
  150. this.id=op.id;
  151. this.getInfo()
  152. },
  153. methods: {
  154. checkboxChange(item,e){
  155. item.checked=e.value
  156. this.$forceUpdate()
  157. console.log(e)
  158. },
  159. confirm(e){
  160. var type=this.showTimeType;
  161. var time=e.hour+":"+e.minute;
  162. if(type==0){
  163. if(this.detail.shareEndTime){
  164. var time1=new Date("2020-1-1 "+time)
  165. var time2=new Date("2020-1-1 "+this.detail.shareEndTime)
  166. if(time1>time2){
  167. this.detail.shareEndTime=null;
  168. }
  169. }
  170. this.detail.shareStartTime=time
  171. }
  172. if(type==1){
  173. if(this.detail.shareStartTime){
  174. var time1=new Date("2020-1-1 "+time)
  175. var time2=new Date("2020-1-1 "+this.detail.shareStartTime)
  176. if(time1<time2){
  177. uni.showToast({
  178. title:"结束时间不可小于开始时间"
  179. })
  180. return
  181. }
  182. }
  183. this.detail.shareEndTime=time
  184. }
  185. },
  186. showTimeBtn(type){
  187. this.showTimeType=type;
  188. console.log(type)
  189. if(type=="0"){
  190. this.showTime=this.detail.shareStartTime
  191. }
  192. if(type=="1"){
  193. this.showTime=this.detail.shareEndTime
  194. }
  195. if(!this.showTime){
  196. this.showTime=new Date().getHours()+":"+new Date().getMinutes()
  197. }
  198. this.show=true;
  199. },
  200. submit(){
  201. var sz=[]
  202. for(var i in this.weekList){
  203. var item=this.weekList[i]
  204. if(item.checked){
  205. sz.push(item.value)
  206. }
  207. }
  208. var weekDay=sz.join();
  209. var sz2=[]
  210. for(var i in this.timeList){
  211. var item=this.timeList[i]
  212. if(item.checked){
  213. sz2.push(item.value)
  214. }
  215. }
  216. var reserveMinutes=sz2.join();
  217. if(!this.detail.shareStartTime){
  218. this.detail.shareStartTime=""
  219. }
  220. if(!this.detail.shareEndTime){
  221. this.detail.shareEndTime=""
  222. }
  223. var weekTime=[this.detail.shareStartTime,this.detail.shareEndTime]
  224. if(this.detail.enableAppointment){
  225. if(weekDay==""){
  226. uni.showToast({
  227. title:"开放预约功能需要选择预约日期"
  228. })
  229. return
  230. }
  231. if(!weekTime[0]){
  232. uni.showToast({
  233. title:"开放预约功能需要预约开始时间"
  234. })
  235. return
  236. }
  237. if(!weekTime[1]){
  238. uni.showToast({
  239. title:"开放预约功能需要预约结束时间"
  240. })
  241. return
  242. }
  243. if(reserveMinutes==""){
  244. uni.showToast({
  245. title:"开放预约功能需要选择预约时长"
  246. })
  247. return
  248. }
  249. console.log( this.detail )
  250. }
  251. this.detail.weekDay=weekDay
  252. this.detail.weekTime=weekTime.join();
  253. this.detail.reserveMinutes=reserveMinutes
  254. uni.showLoading({
  255. title:"加载中",mask:true,
  256. })
  257. API.saveGunShare(this.detail).then((res) => {
  258. uni.hideLoading()
  259. uni.showModal({
  260. title:"提示",
  261. content:"操作成功",
  262. showCancel:false,
  263. success:()=>{
  264. uni.navigateBack({
  265. })
  266. }
  267. })
  268. }).catch(error => {
  269. uni.showToast({
  270. title:error
  271. })
  272. })
  273. },
  274. getInfo(){
  275. uni.showLoading({
  276. title:"加载中",mask:true,
  277. })
  278. API.gunShareDetail({
  279. gunId:this.id
  280. }).then((res) => {
  281. this.detail={};
  282. var obj=res.data.gunShare;
  283. for(var i in obj){
  284. if(obj[i]===true){
  285. this.detail[i]="1";
  286. }else if(obj===false){
  287. this.detail[i]="0";
  288. }else {
  289. this.detail[i]=obj[i];
  290. }
  291. }
  292. if(this.detail.reserveMinutes){
  293. var sz=this.detail.reserveMinutes.split(",")
  294. for(var i in this.timeList){
  295. var item=this.timeList[i]
  296. if(sz.indexOf(item.value)!=-1){
  297. item.checked=true;
  298. }
  299. }
  300. }
  301. if(this.detail.shareWeekDay){
  302. var sz=this.detail.shareWeekDay.split(",")
  303. for(var i in this.weekList){
  304. var item=this.weekList[i]
  305. if(sz.indexOf(item.value)!=-1){
  306. item.checked=true;
  307. }
  308. }
  309. }
  310. console.log(this.detail)
  311. uni.hideLoading()
  312. }).catch(error => {
  313. uni.showToast({
  314. title:error
  315. })
  316. })
  317. }
  318. }
  319. }
  320. </script>
  321. <style lang="scss">
  322. /deep/.u-cell_title {
  323. width: 30% !important;
  324. }
  325. /deep/ .u-cell {
  326. line-height: 20px;
  327. padding: 12px 20px 12px 0;
  328. margin-left: 12px;
  329. }
  330. /deep/.u-radio-group {
  331. justify-content: start !important;
  332. }
  333. /deep/.u-radio-group:last-child {
  334. justify-content: space-between !important;
  335. padding: 0 0 10px 0px;
  336. }
  337. /deep/.u-cell__value {
  338. text-align: left;
  339. color: #101010;
  340. font-size: 16px
  341. }
  342. /deep/.u-radio-group {
  343. line-height: 30px;
  344. width: 100%;
  345. display: flex;
  346. justify-content: space-around;
  347. }
  348. /deep/.border-bottom:after {
  349. border-bottom-width: 0px !important;
  350. }
  351. // 按钮
  352. .bottom{
  353. width: 100%;
  354. height: 56px;
  355. position: fixed;
  356. bottom: 0;
  357. background-color: #fff;
  358. display: flex;
  359. .refuse-btn{
  360. background-color: #DBDBDB;
  361. }
  362. .u-btn{
  363. width: 91.4%;
  364. height: 40px;
  365. margin: auto;
  366. font-size: 18px;
  367. }
  368. .cancel-btn{
  369. width: 91.4%;
  370. background-color: #dbdbdb;
  371. color: #666666
  372. }
  373. }
  374. </style>