index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. <modal v-if="showPop" title="请输入学号" confirm-text="确定" cancel-text="取消" @cancel="cancelPop"
  20. @confirm="confirmPop">
  21. <view class="">学号:</view>
  22. <input type='text' class="stu-number" maxlength="14" placeholder="请输入学号" v-model="stu_number" />
  23. <view class="">身份证号:</view>
  24. <input type='text' class="stu-number" maxlength="18" placeholder="请输入身份证号" v-model="id_card" />
  25. </modal>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. appId: 'wxd6f090391d410534',
  33. ocode: '1015730314',
  34. appSecret: '58D34C81D82B35179ED896C4362B0FC0',
  35. code: '',
  36. amount: 0.00,
  37. showPop: false, //弹窗
  38. stu_number: '20210210140101',
  39. id_card: '88888888'
  40. // stu_number: '',
  41. // id_card: ''
  42. }
  43. },
  44. onLoad() {
  45. this.getCode()
  46. },
  47. methods: {
  48. //弹窗
  49. confirmPop() { //确认
  50. if (this.stu_number.length == 14 && this.id_card.length == 18) {
  51. this.showPop = false
  52. // 获得code
  53. this.getCode()
  54. } else {
  55. uni.showToast({
  56. title: '学号长度错误 或 身份证号 长度错误!',
  57. icon: 'none'
  58. });
  59. }
  60. },
  61. cancelPop() { //取消
  62. // this.stu_number = ''
  63. // this.showPop = false
  64. },
  65. // 获得code
  66. getCode() {
  67. wx.login({
  68. success: (res) => {
  69. // console.log(res);
  70. if (res.code) {
  71. this.code = res.code
  72. // 请求服务器,获得openid
  73. this.getOpenId()
  74. } else {
  75. uni.showToast({
  76. title: res.errMsg,
  77. icon: 'none'
  78. });
  79. }
  80. }
  81. })
  82. },
  83. /**
  84. * 请求服务器,获得openid
  85. */
  86. async getOpenId() {
  87. const res = await this.$myRequest({
  88. host: 'code',
  89. url: '/HotWaters/wpopenid.action',
  90. method: 'POST',
  91. header: {
  92. 'content-type': 'application/x-www-form-urlencoded'
  93. },
  94. data: {
  95. code: this.code,
  96. stu_number: this.stu_number,
  97. id_card: this.id_card
  98. }
  99. })
  100. // console.log(res.data.mess);
  101. if (res.data.mess == '绑定成功') {
  102. uni.showToast({
  103. title: '首次绑定成功!',
  104. icon: 'success'
  105. });
  106. } else if (res.data.mess == '未查询到用户信息') {
  107. this.showPop = true
  108. }
  109. }
  110. }
  111. }
  112. </script>
  113. <style scoped lang="scss">
  114. .container {
  115. display: flex;
  116. flex-direction: column;
  117. width: 750rpx;
  118. font-family: Microsoft YaHei-3970(82674968);
  119. color: #333333;
  120. .banner {
  121. width: 100%;
  122. height: 360rpx;
  123. image {
  124. width: 100%;
  125. height: 100%;
  126. }
  127. }
  128. .nav {
  129. position: relative;
  130. width: 100%;
  131. .menu,
  132. .reset {
  133. margin: 25rpx auto;
  134. width: 640rpx;
  135. }
  136. .menu_item {
  137. display: inline-flex;
  138. flex-direction: column;
  139. text-align: center;
  140. width: 25%;
  141. padding: 30rpx 0 39rpx;
  142. border-radius: 20rpx;
  143. font-family: Microsoft YaHei-3970(82674968);
  144. color: #333333;
  145. image {
  146. width: 90rpx;
  147. height: 90rpx;
  148. margin: 0 auto;
  149. }
  150. text {
  151. height: 29rpx;
  152. line-height: 54rpx;
  153. font-size: 30rpx;
  154. color: #333333;
  155. }
  156. }
  157. }
  158. .stu-number {
  159. margin-top: 20rpx;
  160. color: #00c200;
  161. text-align: center;
  162. font-size: 38rpx;
  163. font-weight: bold;
  164. height: 50rpx;
  165. line-height: 50rpx;
  166. }
  167. }
  168. </style>