ziliao.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <el-form :rules="rules" :model="rulesForm" status-icon ref="ruleForm">
  3. <div class="form-wrap">
  4. <!-- <input type="text" v-model="formMess.id" /> -->
  5. <!-- <h2>{{ formMess.id }}</h2> -->
  6. <el-row>
  7. <el-form-item label="" prop="name" v-if="formMess.isShow" rules="rules">
  8. <el-input class="input" type="text" placeholder="请输入姓名" v-model="formMess.account"></el-input>
  9. </el-form-item>
  10. <el-form-item label="" prop="password" v-if="formMess.isShow" rules="rules">
  11. <el-input class="input" type="text" placeholder="请输入手机号" v-model="formMess.phone">
  12. </el-input>
  13. </el-form-item>
  14. <div class="cen">
  15. <el-form-item class="btn">
  16. <el-button type="success" @click="onSubmits()" v-if="formMess.Shows">注册并签到</el-button>
  17. </el-form-item>
  18. <el-form-item class="btn" >
  19. <el-button type="success" @click="onSubmit()" v-if="formMess.Show">签 到</el-button>
  20. </el-form-item>
  21. </div>
  22. </el-row>
  23. <div v-if="ok" class="success">
  24. <img class="ok-img" src="../../assets/images/qrcode/ok.png" alt="">
  25. </div>
  26. </div>
  27. </el-form>
  28. </template>
  29. <script>
  30. import {
  31. get
  32. } from "@/api/detection/wx.js";
  33. import {
  34. adduser
  35. } from "@/api/detection/wx.js";
  36. export default {
  37. name: "from",
  38. data() {
  39. return {
  40. ok: false, // 判断是否签到成功
  41. formMess: {
  42. account: "",
  43. phone: "",
  44. message: "",
  45. isShow: false,
  46. openid: "666",
  47. Show: true,
  48. Shows: false,
  49. code: "",
  50. // "id": this.$route.params.id // 配置路由 path:'/ziliao/:id'
  51. id: this.$route.query.id, //2
  52. },
  53. };
  54. },
  55. created() {
  56. // // let url = "https://www.baidu.com?name=jimmy&age=18&height=1.88"
  57. // // queryString 为 window.location.search
  58. // const queryString = "?name=jimmy&age=18&height=1.88";
  59. // const queryParams = new URLSearchParams(queryString);
  60. // const paramObj = Object.fromEntries(queryParams);
  61. // console.log(paramObj); // { name: 'jimmy', age: '18', height: '1.88' }
  62. // let queryString=window.location.search
  63. //let queryString=window.location.href
  64. //let queryString = window.location.hash.split("?")[1];
  65. var queryString = window.location.search;
  66. queryString = queryString.substring(1, queryString.length);
  67. var targetPageId = queryString.split("&")[0].split("=")[1];
  68. var state = queryString.split("&")[1].split("=")[1];
  69. console.log(queryString.split("&"));
  70. console.log("state", state);
  71. console.log("queryString", queryString);
  72. console.log("targetPageId", targetPageId)
  73. let queryParams = new URLSearchParams(targetPageId);
  74. let paramObj = Object.fromEntries(queryParams);
  75. console.log("paramObj", paramObj);
  76. console.log("paramObj.code", paramObj.code);
  77. this.formMess.code = targetPageId;
  78. this.formMess.state = state;
  79. },
  80. methods: {
  81. onSubmit() {
  82. let that = this;
  83. let params = {
  84. code: that.formMess.code,
  85. state: that.formMess.state,
  86. };
  87. get(params).then((response) => {
  88. if (response.message == "未注册") {
  89. console.log("rep", response)
  90. that.formMess.openid = response.variables.openid;
  91. that.formMess.isShow = true;
  92. that.formMess.Show = false;
  93. that.formMess.Shows = true;
  94. } else {
  95. that.ok = true, // 判断是否签到成功
  96. that.formMess.Show = false,
  97. alert("签到成功!");
  98. }
  99. });
  100. },
  101. onSubmits() {
  102. let thiss = this;
  103. let data = {
  104. state: thiss.formMess.state,
  105. openid: thiss.formMess.openid,
  106. name: thiss.formMess.account,
  107. mobile: thiss.formMess.phone,
  108. };
  109. console.log("data", data.name);
  110. let params = JSON.stringify(data);
  111. if (data.name && data.mobile != '') {
  112. adduser(params).then((response) => {
  113. console.log("params", params)
  114. console.log("response1", response)
  115. thiss.ok = true
  116. thiss.formMess.isShow = false
  117. thiss.formMess.Shows = false
  118. });
  119. }
  120. },
  121. },
  122. };
  123. </script>
  124. <!-- Add "scoped" attribute to limit CSS to this component only -->
  125. <style scoped lang="less">
  126. .ok-img {
  127. width: 200px;
  128. height: 200px;
  129. }
  130. * {
  131. margin: 0;
  132. padding: 0;
  133. box-sizing: border-box;
  134. }
  135. .app {
  136. width: 100%;
  137. height: 100vh;
  138. display: flex;
  139. align-items: center;
  140. justify-content: center;
  141. padding: 30px;
  142. }
  143. .form-wrap,
  144. .success {
  145. max-width: 800px;
  146. height: 600px;
  147. width: 100%;
  148. height: calc(100vh - 50vh);
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. flex-direction: column;
  153. border-radius: 10px;
  154. background-color: #ffffff;
  155. padding: 15px;
  156. padding-top: 40px;
  157. //box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, .1);
  158. }
  159. .btn {
  160. margin-top: 20px;
  161. min-width: 230px;
  162. display: inline-flex;
  163. align-items: center;
  164. justify-content: center;
  165. // padding: 8px 30px;
  166. border-radius: 4px;
  167. background-color: #85ce61;
  168. color: #fff;
  169. border: 0;
  170. font-size: 15px;
  171. transition: transform .2s ease-in-out;
  172. text-align: center;
  173. /deep/ .el-form-item__content button{
  174. min-width: 230px !important;
  175. line-height:40px
  176. }
  177. }
  178. .input {
  179. // min-width: 230px;
  180. padding: 10px 48px;
  181. // border: 1px solid #85ce61;
  182. // border-radius: 50px;
  183. // color: #333;
  184. }
  185. .cen {
  186. text-align: center;
  187. min-width: 230px;
  188. }
  189. // .btn:hover {
  190. // transform: scale(0.98);
  191. // }
  192. // .from_box {
  193. // form {
  194. // width: 90%;
  195. // margin: auto;
  196. // // border: .01rem solid gray;
  197. // display: flex;
  198. // flex-wrap: wrap;
  199. // input {
  200. // width: 80%;
  201. // height: 0.5rem;
  202. // margin-bottom: 0.2rem;
  203. // border: 0.01rem solid black;
  204. // height: 0.5rem;
  205. // }
  206. // }
  207. // .but {
  208. // font-size: 0.14rem;
  209. // margin-left: 5%;
  210. // }
  211. // }
  212. //label-width="100px"
  213. </style>