index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="container">
  3. <view class="banner">
  4. <image src="../../static/images/banner2x.png" mode=""></image>
  5. </view>
  6. <view class="nav">
  7. <view class="menu">
  8. <navigator :url="'/pages/reshui/reshui'" open-type="redirect" class="menu_item">
  9. <image src="../../static/images/shower2x.png" mode=""></image>
  10. <text>洗 浴</text>
  11. </navigator>
  12. <navigator :url="'/pages/jiaofei/jiaofei?o=index'" open-type="redirect" class="menu_item">
  13. <image src="../../static/images/recharge2x.png" mode=""></image>
  14. <text>电费充值</text>
  15. </navigator>
  16. </view>
  17. </view>
  18. <!--弹窗-->
  19. <<<<<<< HEAD
  20. <modal v-if="showPop" title="用户绑定" confirm-text="确定" cancel-text="重置" @cancel="resetPop" @confirm="confirmPop">
  21. =======
  22. <modal v-if="showPop" title="用户绑定" confirm-text="确定" cancel-text="重置" @cancel="cancelPop"
  23. @confirm="confirmPop">
  24. >>>>>>> 4380156aef5e8beb51c02d4586781d9ce0e14435
  25. <view class="lineGroup">
  26. <text class="iconfont icon-shengchengmingpianicon label-icon"></text>
  27. <input type='text' class="stu-number" maxlength="14" placeholder="请输入学号" v-model="stu_number" />
  28. </view>
  29. <view class="lineGroup">
  30. <text class="iconfont icon-cardid label-icon"></text>
  31. <input type='text' class="stu-number" maxlength="18" placeholder="请输入身份证号码" v-model="id_card" />
  32. </view>
  33. </modal>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. code: '',
  41. showPop: false, //弹窗
  42. stu_number: '',
  43. id_card: '',
  44. ceshi: 'code',
  45. huanjing: '部署环境' // 部署环境是key,用来获取环境
  46. }
  47. },
  48. onLoad() {
  49. // 是否是测试环境,查询数据接口中参数的值决定,方便以后测试
  50. this.isTestEnvironment()
  51. },
  52. methods: {
  53. /**
  54. * 控制环境,test为true测试环境,false则是正式环境
  55. */
  56. async isTestEnvironment() {
  57. const res = await this.$myRequest({
  58. host: this.ceshi,
  59. url: '/HotWaters/conEnvi.action',
  60. method: 'POST',
  61. header: {
  62. 'content-type': 'application/x-www-form-urlencoded'
  63. },
  64. data: {
  65. name: this.huanjing
  66. }
  67. })
  68. // console.log(res);
  69. if (res.data.mess == '返回成功') {
  70. // 0 测试环境, 1 部署环境
  71. if (res.data.data[0].value == 0) {
  72. this.$store.state.test = true
  73. } else {
  74. this.$store.state.test = false
  75. }
  76. } else {
  77. uni.showToast({
  78. title: res.data.mess,
  79. icon: 'success'
  80. });
  81. }
  82. // 获取code
  83. this.getCode()
  84. },
  85. /**
  86. * 弹窗
  87. */
  88. confirmPop() { // 确认
  89. if (this.stu_number.length == 14 && this.id_card.length == 18) {
  90. this.showPop = false
  91. // 获得code
  92. this.getCode('confirm')
  93. } else {
  94. uni.showToast({
  95. title: '学号长度错误 或 身份证号 长度错误!',
  96. icon: 'none'
  97. });
  98. }
  99. },
  100. <<<<<<< HEAD
  101. resetPop() { // 重置
  102. =======
  103. cancelPop() { //取消
  104. >>>>>>> 4380156aef5e8beb51c02d4586781d9ce0e14435
  105. this.stu_number = ''
  106. this.id_card = ''
  107. },
  108. /**
  109. * param获得code
  110. */
  111. getCode(param) {
  112. uni.login({
  113. success: (res) => {
  114. // console.log('index', res);
  115. if (res.code) {
  116. if (param == 'confirm')
  117. // 请求服务器,获得openid
  118. this.getOpenId(res.code)
  119. else
  120. this.selectUser(res.code)
  121. } else {
  122. uni.showToast({
  123. title: res.errMsg,
  124. icon: 'none'
  125. });
  126. }
  127. }
  128. })
  129. },
  130. /**
  131. * 请求服务器,获得openid
  132. */
  133. async getOpenId(code) {
  134. if (this.stu_number == '' || this.id_card == '') {
  135. uni.showToast({
  136. title: '学号或身份证号为空'
  137. });
  138. return
  139. }
  140. const res = await this.$myRequest({
  141. host: this.ceshi,
  142. url: '/HotWaters/wpopenid.action',
  143. method: 'POST',
  144. header: {
  145. 'content-type': 'application/x-www-form-urlencoded'
  146. },
  147. data: {
  148. code: code,
  149. stu_number: this.stu_number,
  150. id_card: this.id_card
  151. }
  152. })
  153. // console.log(res.data.mess);
  154. if (res.data.mess == '绑定成功') {
  155. uni.showToast({
  156. title: '用户绑定成功!',
  157. icon: 'success'
  158. });
  159. } else {
  160. uni.showToast({
  161. title: res.data.mess,
  162. icon: 'success'
  163. });
  164. }
  165. },
  166. /**
  167. * 查询用户
  168. */
  169. async selectUser(code) {
  170. const res = await this.$myRequest({
  171. host: this.ceshi,
  172. url: '/HotWaters/wpget_stu.action',
  173. method: 'POST',
  174. header: {
  175. 'content-type': 'application/x-www-form-urlencoded'
  176. },
  177. data: {
  178. code: code
  179. }
  180. })
  181. // console.log(res);
  182. if (res.data.mess == '未查询到用户信息') {
  183. this.showPop = true
  184. }
  185. }
  186. }
  187. }
  188. </script>
  189. <style scoped lang="scss">
  190. .container {
  191. display: flex;
  192. flex-direction: column;
  193. width: 750rpx;
  194. font-family: Microsoft YaHei-3970(82674968);
  195. color: #333333;
  196. .banner {
  197. width: 100%;
  198. height: 360rpx;
  199. image {
  200. width: 100%;
  201. height: 100%;
  202. }
  203. }
  204. .nav {
  205. position: relative;
  206. width: 100%;
  207. .menu,
  208. .reset {
  209. margin: 25rpx auto;
  210. width: 640rpx;
  211. }
  212. .menu_item {
  213. display: inline-flex;
  214. flex-direction: column;
  215. text-align: center;
  216. width: 25%;
  217. padding: 30rpx 0 39rpx;
  218. border-radius: 20rpx;
  219. font-family: Microsoft YaHei-3970(82674968);
  220. color: #333333;
  221. image {
  222. width: 90rpx;
  223. height: 90rpx;
  224. margin: 0 auto;
  225. }
  226. text {
  227. height: 29rpx;
  228. line-height: 54rpx;
  229. font-size: 30rpx;
  230. color: #333333;
  231. }
  232. }
  233. }
  234. .lineGroup {
  235. display: flex;
  236. flex-direction: row;
  237. border-bottom: 1px solid #c2c2c2;
  238. font-size: 38rpx;
  239. white-space: nowrap;
  240. <<<<<<< HEAD
  241. =======
  242. >>>>>>> 4380156aef5e8beb51c02d4586781d9ce0e14435
  243. .label-icon {
  244. display: flex;
  245. flex-direction: row;
  246. justify-items: right;
  247. align-items: center;
  248. font-size: 58rpx;
  249. width: 88rpx;
  250. height: 88rpx;
  251. line-height: 88rpx;
  252. color: $my-color-primary;
  253. margin: 22rpx 0 0 50rpx;
  254. }
  255. <<<<<<< HEAD
  256. =======
  257. >>>>>>> 4380156aef5e8beb51c02d4586781d9ce0e14435
  258. .stu-number {
  259. margin-top: 20rpx;
  260. color: #00c200;
  261. height: 88rpx;
  262. line-height: 88rpx;
  263. }
  264. }
  265. }
  266. </style>