myPile.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. <template>
  2. <view>
  3. <u-navbar title="充电桩设置"></u-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-model="item.checked"
  42. v-for="(item, index) in weekList" :key="index" :name="item.value"
  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"
  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. confirm(e){
  155. var type=this.showTimeType;
  156. var time=e.hour+":"+e.minute;
  157. if(type==0){
  158. if(this.detail.shareEndTime){
  159. var time1=new Date("2020-1-1 "+time)
  160. var time2=new Date("2020-1-1 "+this.detail.shareEndTime)
  161. if(time1>time2){
  162. this.detail.shareEndTime=null;
  163. }
  164. }
  165. this.detail.shareStartTime=time
  166. }
  167. if(type==1){
  168. if(this.detail.shareStartTime){
  169. var time1=new Date("2020-1-1 "+time)
  170. var time2=new Date("2020-1-1 "+this.detail.shareStartTime)
  171. if(time1<time2){
  172. uni.showToast({
  173. title:"结束时间不可小于开始时间"
  174. })
  175. return
  176. }
  177. }
  178. this.detail.shareEndTime=time
  179. }
  180. },
  181. showTimeBtn(type){
  182. this.showTimeType=type;
  183. console.log(type)
  184. if(type=="0"){
  185. this.showTime=this.detail.shareStartTime
  186. }
  187. if(type=="1"){
  188. this.showTime=this.detail.shareEndTime
  189. }
  190. if(!this.showTime){
  191. this.showTime=new Date().getHours()+":"+new Date().getMinutes()
  192. }
  193. this.show=true;
  194. },
  195. submit(){
  196. var sz=[]
  197. for(var i in this.weekList){
  198. var item=this.weekList[i]
  199. if(item.checked){
  200. sz.push(item.value)
  201. }
  202. }
  203. var weekDay=sz.join();
  204. var sz2=[]
  205. for(var i in this.timeList){
  206. var item=this.timeList[i]
  207. if(item.checked){
  208. sz2.push(item.value)
  209. }
  210. }
  211. var reserveMinutes=sz2.join();
  212. if(!this.detail.shareStartTime){
  213. this.detail.shareStartTime=""
  214. }
  215. if(!this.detail.shareEndTime){
  216. this.detail.shareEndTime=""
  217. }
  218. var weekTime=[this.detail.shareStartTime,this.detail.shareEndTime]
  219. if(this.detail.enableAppointment){
  220. if(weekDay==""){
  221. uni.showToast({
  222. title:"开放预约功能需要选择预约日期"
  223. })
  224. return
  225. }
  226. if(!weekTime[0]){
  227. uni.showToast({
  228. title:"开放预约功能需要预约开始时间"
  229. })
  230. return
  231. }
  232. if(!weekTime[1]){
  233. uni.showToast({
  234. title:"开放预约功能需要预约结束时间"
  235. })
  236. return
  237. }
  238. if(reserveMinutes==""){
  239. uni.showToast({
  240. title:"开放预约功能需要选择预约时长"
  241. })
  242. return
  243. }
  244. console.log( this.detail )
  245. }
  246. this.detail.weekDay=weekDay
  247. this.detail.weekTime=weekTime.join();
  248. this.detail.reserveMinutes=reserveMinutes
  249. uni.showLoading({
  250. title:"加载中",mask:true,
  251. })
  252. API.saveGunShare(this.detail).then((res) => {
  253. uni.hideLoading()
  254. uni.showModal({
  255. title:"提示",
  256. content:"操作成功",
  257. showCancel:false,
  258. success:()=>{
  259. uni.navigateBack({
  260. })
  261. }
  262. })
  263. }).catch(error => {
  264. uni.showToast({
  265. title:error
  266. })
  267. })
  268. },
  269. getInfo(){
  270. uni.showLoading({
  271. title:"加载中",mask:true,
  272. })
  273. API.gunShareDetail({
  274. gunId:this.id
  275. }).then((res) => {
  276. this.detail={};
  277. var obj=res.data.gunShare;
  278. for(var i in obj){
  279. if(obj[i]===true){
  280. this.detail[i]="1";
  281. }else if(obj===false){
  282. this.detail[i]="0";
  283. }else {
  284. this.detail[i]=obj[i];
  285. }
  286. }
  287. if(this.detail.reserveMinutes){
  288. var sz=this.detail.reserveMinutes.split(",")
  289. for(var i in this.timeList){
  290. var item=this.timeList[i]
  291. if(sz.indexOf(item.value)!=-1){
  292. item.checked=true;
  293. }
  294. }
  295. }
  296. if(this.detail.shareWeekDay){
  297. var sz=this.detail.shareWeekDay.split(",")
  298. for(var i in this.weekList){
  299. var item=this.weekList[i]
  300. if(sz.indexOf(item.value)!=-1){
  301. item.checked=true;
  302. }
  303. }
  304. }
  305. console.log(this.detail)
  306. uni.hideLoading()
  307. }).catch(error => {
  308. uni.showToast({
  309. title:error
  310. })
  311. })
  312. }
  313. }
  314. }
  315. </script>
  316. <style lang="scss">
  317. /deep/.u-cell_title {
  318. width: 30% !important;
  319. }
  320. /deep/ .u-cell {
  321. line-height: 20px;
  322. padding: 12px 20px 12px 0;
  323. margin-left: 12px;
  324. }
  325. /deep/.u-radio-group {
  326. justify-content: start !important;
  327. }
  328. /deep/.u-radio-group:last-child {
  329. justify-content: space-between !important;
  330. padding: 0 0 10px 0px;
  331. }
  332. /deep/.u-cell__value {
  333. text-align: left;
  334. color: #101010;
  335. font-size: 16px
  336. }
  337. /deep/.u-radio-group {
  338. line-height: 30px;
  339. width: 100%;
  340. display: flex;
  341. justify-content: space-around;
  342. }
  343. /deep/.border-bottom:after {
  344. border-bottom-width: 0px !important;
  345. }
  346. // 按钮
  347. .bottom{
  348. width: 100%;
  349. height: 56px;
  350. position: fixed;
  351. bottom: 0;
  352. background-color: #fff;
  353. display: flex;
  354. .refuse-btn{
  355. background-color: #DBDBDB;
  356. }
  357. .u-btn{
  358. width: 91.4%;
  359. height: 40px;
  360. margin: auto;
  361. font-size: 18px;
  362. }
  363. .cancel-btn{
  364. width: 91.4%;
  365. background-color: #dbdbdb;
  366. color: #666666
  367. }
  368. }
  369. </style>