index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template >
  2. <view>
  3. <cu-custom class="home-custom" bgColor=".bg-sancolor" bgImage="https://ahwgh.oss-cn-hangzhou.aliyuncs.com/enterprise/6525f808df760.png" :isBack="true" >
  4. <block slot="content">精准大田专家填报系统</block>
  5. </cu-custom>
  6. <scroll-view scroll-y class="page">
  7. <view>
  8. <view class=" cu-bar bg-white solid-bottom margin-top" >
  9. <view class="action">
  10. <text class="cuIcon-title text-blue"></text> 信息填报
  11. </view>
  12. </view>
  13. <view class="cu-list menu margin-top">
  14. <view class="cu-form-group">
  15. <view class="title must">专家名称</view>
  16. <input type="text" :value="userInfo.author">
  17. </view>
  18. <view class="cu-form-group">
  19. <view class="title must">位置选择</view>
  20. <picker :value="userInfo.site" :range="pickerRange" @change="caseTypeChange">
  21. <view class="picker">
  22. {{ userInfo.site ?userInfo.site :'请选择'}}
  23. </view>
  24. </picker>
  25. </view>
  26. <view class="cu-form-group">
  27. <view class="title must">指导时间</view>
  28. <input type="text" :value="userInfo.pzdt" disabled>
  29. </view>
  30. <view class="cu-bar bg-white ">
  31. <view class="action must">
  32. 现场图片
  33. </view>
  34. <view class="action">
  35. {{ imgList.length }}/1
  36. </view>
  37. </view>
  38. <view class="cu-form-group">
  39. <view class="grid col-4 grid-square flex-sub">
  40. <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" :data-url="imgList[index]">
  41. <image :src="imgList[index]" mode="aspectFill"></image>
  42. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
  43. <text class='cuIcon-close'></text>
  44. </view>
  45. </view>
  46. <view class="solids" @tap="ChooseImage" v-if="imgList.length<1">
  47. <text class='cuIcon-cameraadd'></text>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="padding flex flex-direction">
  53. <button class="cu-btn bg-blue lg margin-tb-sm shadow-blur text-lg"
  54. @click="submit" type="" >提交
  55. </button>
  56. </view>
  57. </view>
  58. <view class="footer">
  59. <view>主办单位:安徽省农业农村厅质监处</view>
  60. <view>技术支持:安徽省北斗精准农业信息工程实验室</view>
  61. </view>
  62. <view class="cu-tabbar-height"></view>
  63. </scroll-view>
  64. </view>
  65. </template>
  66. <script>
  67. import { Messages } from "prettier/parser-postcss";
  68. import { _home } from "./check.js";
  69. export default {
  70. name: "basics",
  71. data() {
  72. return {
  73. cardCur: 0,
  74. dotStyle: false,
  75. towerStart: 0,
  76. direction: "",
  77. userInfo:{},
  78. imgList: [],//图片list
  79. caseTypeList:[],//'黑塔镇蒋杨村','韦集镇陈圩村','灵城镇界沟村','支河镇鸭湖村'
  80. };
  81. },
  82. computed: {
  83. pickerRange() {
  84. return this.caseTypeList.map(item => item.site);
  85. }
  86. },
  87. created() {
  88. const now = new Date();
  89. const year = now.getFullYear();
  90. const month = now.getMonth() + 1;
  91. const day = now.getDate();
  92. const today = year + "-" + (month >= 10 ? month : ("0" + month)) + "-" + (day >= 10 ? day : ("0" + day));
  93. this.$set(this.userInfo, "pzdt", today);
  94. this.getLo();
  95. this.$set(this.userInfo,"author",wx.getStorageSync('username'));
  96. console.log("缓存"+wx.getStorageSync('username'))
  97. this.toNextPage();
  98. },
  99. methods: {
  100. getLocation() {
  101. return new Promise((resolve, reject) => {
  102. uni.getLocation({
  103. type: 'gcj02',
  104. success: res => {
  105. console.log('当前位置的经度:' + res.longitude);
  106. console.log('当前位置的纬度:' + res.latitude);
  107. const {latitude: lat, longitude: lng} = res;
  108. resolve(res);
  109. },
  110. fail: err => {
  111. this.$msg("位置获取失败");
  112. reject("位置获取失败");
  113. }
  114. });
  115. })
  116. },
  117. getLo(){
  118. console.log("1111111")
  119. uni.showLoading({
  120. title:'获取位置中...'
  121. });
  122. this.getLocation().then(res => {
  123. console.log(res)
  124. _home.location({
  125. volatitude:res.latitude,
  126. volongitude:res.longitude
  127. },res=>{
  128. uni.hideLoading();
  129. console.log(res)
  130. console.log(res.data.data[1].site)
  131. var a=[];
  132. a=res.data.data;
  133. this.caseTypeList=[];
  134. for (let i = 0; i < a.length; i++) {
  135. this.caseTypeList.push({
  136. id:i,
  137. site:a[i].site,
  138. })
  139. }
  140. })
  141. /* const {latitude: lat, longitude: lng} = res;
  142. if(!lat || !lng){
  143. this.$msg("位置信息获取失败");
  144. this.disableFirstBtn = false;
  145. }
  146. this.$set(this.checkInfo, "check_lng", lng)
  147. this.$set(this.checkInfo, "check_lat", lat) */
  148. })
  149. },
  150. /**
  151. * 类型选择事件
  152. * **/
  153. caseTypeChange(e){
  154. console.log(e.detail.value);
  155. //this.userInfo.case_type=e.detail.value;
  156. this.$set(this.userInfo,"site",this.caseTypeList[e.detail.value].site)
  157. },
  158. submit(){
  159. var that=this;
  160. this.$set(this.userInfo,"imgurl",this.imgList.join(','))
  161. console.log(this.userInfo);
  162. wx.showModal({
  163. title: '提示', //提示的标题
  164. content: '确定提交吗?', //提示的内容
  165. success: function(res) {
  166. if(res.confirm) {
  167. _home.getLandImg(that.userInfo,res=>{
  168. console.log(res)
  169. if(res.data.code===1){
  170. that.$msg("上报成功!");
  171. delete that.userInfo.imgurl;
  172. delete that.userInfo.site;
  173. that.imgList=[]
  174. }else{
  175. that.$msg("上报失败!");
  176. }
  177. })
  178. }
  179. }
  180. })
  181. },
  182. //照片
  183. ChooseImage() {
  184. uni.chooseImage({
  185. count:3, //默认9
  186. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  187. sourceType: ['album', 'camera'], //从相册选择
  188. success: (res) => {
  189. console.log(res)
  190. uni.showLoading({
  191. title: '图片上传中'
  192. })
  193. _home.ChooseImage(res.tempFilePaths[0], res => {
  194. console.log('返回的结果',res)
  195. let data = res.data
  196. data = JSON.parse(data)
  197. console.log(data)
  198. var url=data.data;
  199. console.log(url);
  200. if (this.imgList.length !== 0) {
  201. this.imgList = this.imgList.concat(data.data)
  202. } else {
  203. this.imgList = [data.data]
  204. }
  205. //this.userInfo.report_image.push(url)
  206. this.$set(this.userInfo,"imgurl",url)
  207. uni.hideLoading()
  208. })
  209. }
  210. });
  211. },
  212. DelImg(e) {
  213. uni.showModal({
  214. title: '图片删除',
  215. content: '确定要删除图片吗?',
  216. cancelText: '取消',
  217. confirmText: '确认',
  218. success: res => {
  219. console.log(res)
  220. if (res.confirm) {
  221. /* this.infoList.product_images.splice(e.currentTarget.dataset.index, 1);
  222. this.imgList.splice(e.currentTarget.dataset.index, 1); */
  223. this.imgList.splice(e.currentTarget.dataset.index, 1)
  224. }
  225. }
  226. })
  227. },
  228. ViewImage(index) {
  229. uni.previewImage({
  230. urls: this.imgList,
  231. current: e.currentTarget.dataset.url
  232. });
  233. },
  234. toNextPage() {
  235. console.log("判断登录");
  236. //判断有没有登录,没有登录直接跳到登录,登录了 跳到任务详情
  237. let username = wx.getStorageSync("username");
  238. if (username == "") {
  239. //没有登录
  240. console.log("没有登录");
  241. //跳入登录
  242. uni.navigateTo({
  243. url: "/pages/login/index"
  244. });
  245. } else {
  246. console.log("已登录")
  247. /* let role = uni.getStorageSync("role");
  248. console.log(index)
  249. if (index == 2 ) { //抽样人员的角色id
  250. //表示点了抽样单位且角色是抽样单位
  251. if(role === '85f63893de834bb898edc01cfd2cc46c'){
  252. //检测机构人员
  253. uni.navigateTo({
  254. url: "/pages/sample-check-list/home"
  255. });
  256. } else if(role === "f35551e4a06647dea5c2c43aaba22c2a"){
  257. uni.navigateTo({
  258. url: "/pages/task-list/index"
  259. });
  260. }else{
  261. uni.showToast({
  262. icon: 'error',
  263. title: "当前角色不可查看",
  264. duration: 1500
  265. })
  266. }
  267. }
  268. if (index == 0 && role == "a1cbf841b0514b47bbdd3f50c80b729f") { //快检站的角色
  269. //表示点了检测单位且角色是检测单位
  270. uni.navigateTo({
  271. url: "/pages/quick-task/list"
  272. });
  273. }
  274. if (index == 1) {
  275. // && role == "a1cbf841b0514b47bbdd3f50c80b729f"
  276. uni.navigateTo({
  277. url: "/pages/quick-task/quick-list"
  278. });
  279. } */
  280. }
  281. }
  282. }
  283. };
  284. </script>
  285. <style>
  286. .page {
  287. height: 100vh;
  288. }
  289. .footer {
  290. position: fixed;
  291. text-align: center;
  292. line-height: 40px;
  293. margin-bottom: 2px;
  294. bottom: 10vh;
  295. width: 100%;
  296. font-size: 12px;
  297. }
  298. .footer view {
  299. line-height: 22px;
  300. }
  301. </style>