addbase.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view>
  3. <view style="position: fixed;z-index: 100;">
  4. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="新增基地"></uni-nav-bar>
  5. </view>
  6. <view class="addimg">
  7. <view class="addimg_add" @click="gainimg">
  8. <u-icon name="plus" size="60rpx" color="#A5A6A8"></u-icon>
  9. <image :src="userinfos" mode="" class="addimg_img"></image>
  10. </view>
  11. </view>
  12. <view class="base_text">
  13. <p class="title">基地信息</p>
  14. <view class="base_text_item1">
  15. <u-icon name="fangzi" custom-prefix="custom-icon" class="icon"></u-icon>
  16. <span>基地名称</span>
  17. <input type="text" value="" placeholder="请输入基地名称" />
  18. </view>
  19. <view class="base_text_item1">
  20. <u-icon name="ren1" custom-prefix="custom-icon" class="icon"></u-icon>
  21. <span>负责人</span>
  22. <input type="text" value="" placeholder="请输入基地负责人" />
  23. </view>
  24. <view class="base_text_item1">
  25. <u-icon name="lianxidianhua" custom-prefix="custom-icon" class="icon"></u-icon>
  26. <span>联系电话</span>
  27. <input type="text" value="" placeholder="请输入联系电话" />
  28. </view>
  29. <view class="base_text_item1">
  30. <u-icon name="mianji" custom-prefix="custom-icon" class="icon"></u-icon>
  31. <span>面积(亩)</span>
  32. <input type="number" value="" placeholder="请输入基地面积" />
  33. </view>
  34. <view class="base_text_item2">
  35. <u-icon name="miaoshu" custom-prefix="custom-icon" class="icon"></u-icon>
  36. <span>基地描述</span>
  37. <textarea value="" placeholder="" auto-height class="textarea" placeholder="请输入基地描述" />
  38. </view>
  39. <view class="base_text_item1" @click="map">
  40. <u-icon name="Frame1" custom-prefix="custom-icon" class="icon"></u-icon>
  41. <span>基地定位</span>
  42. <u-icon name="arrow-right" class="iconright"></u-icon>
  43. </view>
  44. <view class="base_text_item1" @click="binding">
  45. <u-icon name="bangding" custom-prefix="custom-icon" class="icon"></u-icon>
  46. <span>设备绑定</span>
  47. <u-icon name="arrow-right" class="iconright"></u-icon>
  48. </view>
  49. <view class="base_id_box">
  50. <view class="base_id" v-for="(item,key,index) in base_id" :key="index">
  51. <view class="base_id_item" v-for="(items,indexs) in item" :key="indexs">
  52. <span>{{key}}</span>
  53. <span>{{items}}</span>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="btn">
  58. 确 定
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <style lang="scss">
  64. </style>
  65. <script>
  66. export default {
  67. data() {
  68. return {
  69. base_id:{},
  70. userinfos:''
  71. }
  72. },
  73. methods: {
  74. clickLeft(){
  75. uni.navigateTo({
  76. url:"./index"
  77. })
  78. },
  79. binding(){
  80. uni.navigateTo({
  81. url:"./allocation"
  82. })
  83. },
  84. gainimg() { //添加图片
  85. uni.chooseImage({
  86. count: 1, //默认9
  87. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  88. sourceType: ['album', 'camera'], //从相册选择
  89. success: (res) => {
  90. uni.uploadFile({
  91. url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  92. filePath: res.tempFilePaths[0],
  93. name: 'img_file',
  94. formData: {
  95. 'user': 'test'
  96. },
  97. success: (uploadFileRes) => {
  98. this.userinfos = JSON.parse(uploadFileRes.data).data.src
  99. console.log(this.userinfos)
  100. this.$forceUpdate() //强制刷新视图
  101. }
  102. });
  103. }
  104. })
  105. },
  106. map(){
  107. // uni.chooseLocation({
  108. // success: function (res) {
  109. // console.log('位置名称:' + res.name);
  110. // console.log('详细地址:' + res.address);
  111. // console.log('纬度:' + res.latitude);
  112. // console.log('经度:' + res.longitude);
  113. // }
  114. // });
  115. uni.navigateTo({
  116. url:"./fourbasemap"
  117. })
  118. }
  119. },
  120. onLoad(option) {
  121. console.log(option=={})
  122. if(JSON.stringify(option) != "{}"){
  123. this.base_id=JSON.parse(option.id)
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss">
  129. .addimg{
  130. position: absolute;
  131. top: 108rpx;
  132. width: 100%;
  133. .addimg_add{
  134. position: relative;
  135. width: 90%;
  136. height: 276rpx;
  137. margin: 0 auto;
  138. background-color: #F7F8FA;
  139. text-align: center;
  140. line-height: 276rpx;
  141. color: #A7A8AA;
  142. .addimg_img{
  143. position: absolute;
  144. top: 0;
  145. width: 100%;
  146. left: 0;
  147. height: 276rpx;
  148. }
  149. }
  150. }
  151. .base_text{
  152. position: absolute;
  153. top: 390rpx;
  154. width: 100%;
  155. .title{
  156. width: 90%;
  157. margin: 20rpx auto;
  158. }
  159. .base_text_item2{
  160. width: 90%;
  161. margin: 10rpx auto 20rpx;
  162. padding: 16rpx 20rpx;
  163. background-color: #F7F8FA;
  164. display: flex;
  165. .icon{
  166. color: #5FBBA0;
  167. height: 42rpx;
  168. }
  169. span{
  170. margin: 0 20rpx;
  171. }
  172. .textarea{
  173. font-size: 24rpx;
  174. margin-left: 20rpx;
  175. width: 426rpx;
  176. text-align: right;
  177. }
  178. }
  179. .base_text_item1{
  180. display: flex;
  181. position: relative;
  182. width: 90%;
  183. height: 70rpx;
  184. margin: 10rpx auto 20rpx;
  185. padding: 16rpx 20rpx;
  186. background-color: #F7F8FA;
  187. .icon{
  188. color: #5FBBA0;
  189. }
  190. span{
  191. margin: 0 20rpx;
  192. }
  193. input{
  194. position: absolute;
  195. right: 20rpx;
  196. width: 70%;
  197. text-align: right;
  198. font-size: 24rpx;
  199. margin-top: 5rpx;
  200. }
  201. .iconright{
  202. position: absolute;
  203. right: 20rpx;
  204. top: 28rpx;
  205. color: #B5B6B8;
  206. font-size: 24rpx;
  207. }
  208. }
  209. }
  210. .base_id_box{
  211. width: 90%;
  212. margin: 20rpx auto 70rpx;
  213. }
  214. .base_id{
  215. width: 100%;
  216. display: flex;
  217. justify-content: space-between;
  218. flex-wrap: wrap;
  219. .base_id_item{
  220. width: 48%;
  221. padding: 10rpx 30rpx;
  222. display: flex;
  223. justify-content: space-between;
  224. font-size: 28rpx;
  225. background-color: #F7F8FA;
  226. color: #B8B8BA;
  227. margin-bottom: 10rpx;
  228. }
  229. }
  230. .btn{
  231. width: 90%;
  232. position: fixed;
  233. bottom: 0;
  234. right: 5%;
  235. text-align: center;
  236. height: 70rpx;
  237. line-height: 70rpx;
  238. background-color: #359773;
  239. font-size: 34rpx;
  240. border-radius: 35rpx;
  241. color: #FFFFFF;
  242. }
  243. </style>