myPile.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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. this.show=true;
  191. },
  192. submit(){
  193. var sz=[]
  194. for(var i in this.weekList){
  195. var item=this.weekList[i]
  196. if(item.checked){
  197. sz.push(item.value)
  198. }
  199. }
  200. var weekDay=sz.join();
  201. var sz2=[]
  202. for(var i in this.timeList){
  203. var item=this.timeList[i]
  204. if(item.checked){
  205. sz2.push(item.value)
  206. }
  207. }
  208. var reserveMinutes=sz2.join();
  209. var weekTime=[this.detail.shareStartTime,this.detail.shareEndTime]
  210. if(this.detail.enableAppointment){
  211. if(weekDay==""){
  212. uni.showToast({
  213. title:"开放预约功能需要选择预约日期"
  214. })
  215. return
  216. }
  217. this.detail.weekDay=weekDay
  218. this.detail.reserveMinutes=reserveMinutes
  219. if(!weekTime[0]){
  220. uni.showToast({
  221. title:"开放预约功能需要预约开始时间"
  222. })
  223. return
  224. }
  225. if(!weekTime[1]){
  226. uni.showToast({
  227. title:"开放预约功能需要预约结束时间"
  228. })
  229. return
  230. }
  231. if(reserveMinutes==""){
  232. uni.showToast({
  233. title:"开放预约功能需要选择预约时长"
  234. })
  235. return
  236. }
  237. this.detail.weekTime=weekTime
  238. console.log( this.detail )
  239. }
  240. uni.showLoading({
  241. title:"加载中",mask:true,
  242. })
  243. API.saveGunShare(this.detail).then((res) => {
  244. uni.hideLoading()
  245. uni.showToast({
  246. title:"操作成功"
  247. })
  248. }).catch(error => {
  249. uni.showToast({
  250. title:error
  251. })
  252. })
  253. },
  254. getInfo(){
  255. uni.showLoading({
  256. title:"加载中",mask:true,
  257. })
  258. API.gunShareDetail({
  259. gunId:this.id
  260. }).then((res) => {
  261. this.detail={};
  262. var obj=res.data.gunShare;
  263. for(var i in obj){
  264. if(obj[i]===true){
  265. this.detail[i]="1";
  266. }else if(obj===false){
  267. this.detail[i]="0";
  268. }else {
  269. this.detail[i]=obj[i];
  270. }
  271. }
  272. if(this.detail.reserveMinutes){
  273. var sz=this.detail.reserveMinutes.split(",")
  274. for(var i in this.timeList){
  275. var item=this.timeList[i]
  276. if(sz.indexOf(item.value)!=-1){
  277. item.checked=true;
  278. }
  279. }
  280. }
  281. if(this.detail.shareWeekDay){
  282. var sz=this.detail.shareWeekDay.split(",")
  283. for(var i in this.weekList){
  284. var item=this.weekList[i]
  285. if(sz.indexOf(item.value)!=-1){
  286. item.checked=true;
  287. }
  288. }
  289. }
  290. console.log(this.detail)
  291. uni.hideLoading()
  292. }).catch(error => {
  293. uni.showToast({
  294. title:error
  295. })
  296. })
  297. }
  298. }
  299. }
  300. </script>
  301. <style lang="scss">
  302. /deep/.u-cell_title {
  303. width: 30% !important;
  304. }
  305. /deep/ .u-cell {
  306. line-height: 20px;
  307. padding: 12px 20px 12px 0;
  308. margin-left: 12px;
  309. }
  310. /deep/.u-radio-group {
  311. justify-content: start !important;
  312. }
  313. /deep/.u-radio-group:last-child {
  314. justify-content: space-between !important;
  315. padding: 0 0 10px 0px;
  316. }
  317. /deep/.u-cell__value {
  318. text-align: left;
  319. color: #101010;
  320. font-size: 16px
  321. }
  322. /deep/.u-radio-group {
  323. line-height: 30px;
  324. width: 100%;
  325. display: flex;
  326. justify-content: space-around;
  327. }
  328. /deep/.border-bottom:after {
  329. border-bottom-width: 0px !important;
  330. }
  331. // 按钮
  332. .bottom{
  333. width: 100%;
  334. height: 56px;
  335. position: fixed;
  336. bottom: 0;
  337. background-color: #fff;
  338. display: flex;
  339. .refuse-btn{
  340. background-color: #DBDBDB;
  341. }
  342. .u-btn{
  343. width: 91.4%;
  344. height: 40px;
  345. margin: auto;
  346. font-size: 18px;
  347. }
  348. .cancel-btn{
  349. width: 91.4%;
  350. background-color: #dbdbdb;
  351. color: #666666
  352. }
  353. }
  354. </style>