add_park.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <view>
  3. <view class="addPop">
  4. <view style="text-align:center;">区域信息</view>
  5. <view class="flex select">
  6. <text>所属大区</text>
  7. <picker @change="bindPickerChange" :value="index" :range="arr">
  8. <!-- <text>{{arr[index]}}</text> -->
  9. <input type="text" :value="arr[index]" disabled="true"/>
  10. </picker>
  11. </view>
  12. <view class="flex">
  13. <text>停车区域名称</text>
  14. <input placeholder="请输入停车区名称" placeholder-class="place" @input="bindKeyInput" @blur="bindKeyInput" :value="parkName"></input>
  15. </view>
  16. <view class="flex select">
  17. <text>区域类型</text>
  18. <picker @change="bindPickerChange1" :value="listIndex" :range="typelist1">
  19. <!-- <text>{{typelist1[listIndex]}}</text> -->
  20. <input type="text" :value="typelist1[listIndex]" disabled="true"/>
  21. </picker>
  22. </view>
  23. <view class="flex">
  24. <text>停车上限</text>
  25. <input placeholder-class="place" type="number" @input="numInput" @blur="numInput" :value="parkNum"></input>
  26. </view>
  27. <view class="handel flexA">
  28. <view @click="draw">绘制围栏</view>
  29. <view @click="cancel">取消</view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. const app = getApp();
  36. export default {
  37. data() {
  38. return {
  39. showType: false,
  40. showArea: false,
  41. parkNum: '',
  42. parkName: '',
  43. array: [],
  44. arr: [],
  45. index: 0,
  46. typeList: [{ //区域类型选项
  47. type: 1,
  48. name: '禁停区'
  49. }, {
  50. type: 2,
  51. name: '停车区'
  52. }],
  53. typelist1: ['禁停区', '停车区'],
  54. areaName: '',
  55. areaId: '',
  56. listIndex: 0,
  57. typeName:''
  58. }
  59. },
  60. methods: {
  61. //取消
  62. cancel: function() {
  63. wx.navigateBack()
  64. },
  65. numInput: function(e) {
  66. this.parkNum = e.detail.value
  67. },
  68. draw: function() {
  69. let that = this;
  70. if (!that.areaName) {
  71. uni.showToast({
  72. title: '请选择所属大区',
  73. icon: 'none'
  74. })
  75. console.log(that.areaName)
  76. } else if (!that.parkName) {
  77. uni.showToast({
  78. title: '停车区域名称不能为空',
  79. icon: 'none'
  80. })
  81. console.log(that.parkName)
  82. } else if (!that.typeName) {
  83. uni.showToast({
  84. title: '请选择区域类型',
  85. icon: 'none'
  86. })
  87. console.log(that.typeName)
  88. }
  89. // else if (that.parkNum == '') {
  90. // uni.showToast({
  91. // title: '请输入停车上限',
  92. // icon: 'none'
  93. // })
  94. // console.log(that.parkNum)
  95. // }
  96. else {
  97. console.log('成立')
  98. let data = {
  99. name: this.parkName
  100. }
  101. app.request('parking/UniqueParkingName', data, 'POST').then(res => {
  102. if (res.statusCode == 200) {
  103. if (res.data.status == 0) {
  104. uni.showToast({
  105. title: '停车区域名称已存在',
  106. icon: 'none'
  107. })
  108. } else {
  109. var pages = getCurrentPages();
  110. var prevPage = pages[pages.length - 2]; //上一个页面
  111. console.log(prevPage)
  112. prevPage.$vm.areaId=this.areaId;
  113. prevPage.$vm.parkName=this.parkName;
  114. prevPage.$vm.parkNum=this.parkNum;
  115. prevPage.$vm.type=this.listIndex+1;
  116. prevPage.$vm.mapclick=true;
  117. uni.navigateBack()
  118. }
  119. }
  120. })
  121. }
  122. },
  123. // change: function(e) {
  124. // uni.setStorageSync('curVal', this.option1[e.detail.value].value)
  125. // uni.setStorageSync('curId', this.option1[e.detail.value].areaID)
  126. // this.areaID = this.option1[e.detail].areaID;
  127. // this.park()
  128. // },
  129. //停车(禁停)区名称
  130. bindKeyInput: function(e) {
  131. console.log(e)
  132. this.parkName = e.detail.value;
  133. },
  134. bindPickerChange: function(e) {
  135. console.log(e)
  136. let nowArea = this.array[e.detail.value].text
  137. let areaId = this.array[e.detail.value].areaID
  138. this.areaName = nowArea;
  139. this.areaId = areaId;
  140. this.index = e.detail.value;
  141. console.log(this.areaName,this.areaId,this.index)
  142. },
  143. bindPickerChange1: function(e) {
  144. console.log(e)
  145. this.typeName = this.typeList[e.detail.value].name;
  146. this.type = this.typeList[e.detail.value].type;
  147. this.listIndex = e.detail.value;
  148. console.log(this.typeName)
  149. console.log(this.type)
  150. },
  151. },
  152. onLoad(options) {
  153. let that = this;
  154. that.array = uni.getStorageSync('allArea');
  155. console.log(that.array)
  156. var options = that.array;
  157. var arr = [];
  158. for (var i = 0; i < options.length; i++) {
  159. arr.push(options[i].text)
  160. }
  161. that.arr = arr;
  162. let curVal = wx.getStorageSync('curVal');
  163. if (curVal) {
  164. that.value1 = curVal;
  165. }
  166. let areaID = wx.getStorageSync('curId')
  167. if (areaID) {
  168. that.areaID = areaID;
  169. } else {
  170. let id = options[0].areaID
  171. that.areaID = id;
  172. }
  173. console.log(this.typeList)
  174. this.areaName = options[0].text;
  175. this.typeName = this.typeList[0].name;
  176. this.areaId = options[0].areaID;
  177. }
  178. }
  179. </script>
  180. <style>
  181. page {
  182. height: 100%;
  183. background: #A9A9A9;
  184. }
  185. .addPop {
  186. position: absolute;
  187. top: 50%;
  188. left: 50%;
  189. transform: translate(-50%, -50%);
  190. width: 80%;
  191. height: 600upx;
  192. background: #fff;
  193. border-radius: 10upx;
  194. z-index: 2222;
  195. padding: 30upx 20upx;
  196. }
  197. .addPop>view {
  198. margin-bottom: 15upx;
  199. font-size: 28upx;
  200. height: 70upx;
  201. }
  202. .addPop>view input {
  203. border: 1upx solid #dcdfe6;
  204. border-radius: 10upx;
  205. margin-left: 20upx;
  206. height: 68upx;
  207. width: 362upx;
  208. padding-left: 10upx;
  209. }
  210. .place {
  211. font-size: 26upx;
  212. color: #ddd;
  213. }
  214. .addPop>view text {
  215. display: inline-block;
  216. width: 180upx;
  217. text-align: right;
  218. }
  219. .select image {
  220. width: 40upx;
  221. height: 30upx;
  222. }
  223. .select .picker {
  224. border: 1upx solid #dcdfe6;
  225. border-radius: 10upx;
  226. margin-left: 20upx;
  227. height: 70upx;
  228. width: 374upx;
  229. }
  230. .select .picker input {
  231. width: 83%;
  232. border: none;
  233. margin-left: 0;
  234. }
  235. .handel {
  236. margin-top: 40upx;
  237. display: flex;
  238. align-items: center;
  239. justify-content: space-around;
  240. }
  241. .handel view {
  242. text-align: center;
  243. background: #18d5b9;
  244. color: #fff;
  245. width: 200upx;
  246. height: 60upx;
  247. line-height: 60upx;
  248. border-radius: 43upx;
  249. font-size: 28upx;
  250. }
  251. .flex {
  252. display: flex;
  253. align-items: center;
  254. }
  255. </style>