myPile.vue 7.8 KB

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