index.vue 9.0 KB

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