| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <template>
- <view class="container">
- <view class="banner">
- <image src="../../static/images/banner2x.png" mode=""></image>
- </view>
- <view class="nav">
- <view class="menu">
- <navigator :url="'/pages/reshui/reshui'" open-type="redirect" class="menu_item">
- <image src="../../static/images/shower2x.png" mode=""></image>
- <text>洗 浴</text>
- </navigator>
- <navigator :url="'/pages/jiaofei/jiaofei?o=index'" open-type="redirect" class="menu_item">
- <image src="../../static/images/recharge2x.png" mode=""></image>
- <text>电费充值</text>
- </navigator>
- </view>
- </view>
- <!--弹窗-->
- <<<<<<< HEAD
- <modal v-if="showPop" title="用户绑定" confirm-text="确定" cancel-text="重置" @cancel="resetPop" @confirm="confirmPop">
- =======
- <modal v-if="showPop" title="用户绑定" confirm-text="确定" cancel-text="重置" @cancel="cancelPop"
- @confirm="confirmPop">
- >>>>>>> 4380156aef5e8beb51c02d4586781d9ce0e14435
- <view class="lineGroup">
- <text class="iconfont icon-shengchengmingpianicon label-icon"></text>
- <input type='text' class="stu-number" maxlength="14" placeholder="请输入学号" v-model="stu_number" />
- </view>
- <view class="lineGroup">
- <text class="iconfont icon-cardid label-icon"></text>
- <input type='text' class="stu-number" maxlength="18" placeholder="请输入身份证号码" v-model="id_card" />
- </view>
- </modal>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- code: '',
- showPop: false, //弹窗
- stu_number: '',
- id_card: '',
- ceshi: 'code',
- huanjing: '部署环境' // 部署环境是key,用来获取环境
- }
- },
- onLoad() {
- // 是否是测试环境,查询数据接口中参数的值决定,方便以后测试
- this.isTestEnvironment()
- },
- methods: {
- /**
- * 控制环境,test为true测试环境,false则是正式环境
- */
- async isTestEnvironment() {
- const res = await this.$myRequest({
- host: this.ceshi,
- url: '/HotWaters/conEnvi.action',
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- name: this.huanjing
- }
- })
- // console.log(res);
- if (res.data.mess == '返回成功') {
- // 0 测试环境, 1 部署环境
- if (res.data.data[0].value == 0) {
- this.$store.state.test = true
- } else {
- this.$store.state.test = false
- }
- } else {
- uni.showToast({
- title: res.data.mess,
- icon: 'success'
- });
- }
- // 获取code
- this.getCode()
- },
- /**
- * 弹窗
- */
- confirmPop() { // 确认
- if (this.stu_number.length == 14 && this.id_card.length == 18) {
- this.showPop = false
- // 获得code
- this.getCode('confirm')
- } else {
- uni.showToast({
- title: '学号长度错误 或 身份证号 长度错误!',
- icon: 'none'
- });
- }
- },
- <<<<<<< HEAD
- resetPop() { // 重置
- =======
- cancelPop() { //取消
- >>>>>>> 4380156aef5e8beb51c02d4586781d9ce0e14435
- this.stu_number = ''
- this.id_card = ''
- },
- /**
- * param获得code
- */
- getCode(param) {
- uni.login({
- success: (res) => {
- // console.log('index', res);
- if (res.code) {
- if (param == 'confirm')
- // 请求服务器,获得openid
- this.getOpenId(res.code)
- else
- this.selectUser(res.code)
- } else {
- uni.showToast({
- title: res.errMsg,
- icon: 'none'
- });
- }
- }
- })
- },
- /**
- * 请求服务器,获得openid
- */
- async getOpenId(code) {
- if (this.stu_number == '' || this.id_card == '') {
- uni.showToast({
- title: '学号或身份证号为空'
- });
- return
- }
- const res = await this.$myRequest({
- host: this.ceshi,
- url: '/HotWaters/wpopenid.action',
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- code: code,
- stu_number: this.stu_number,
- id_card: this.id_card
- }
- })
- // console.log(res.data.mess);
- if (res.data.mess == '绑定成功') {
- uni.showToast({
- title: '用户绑定成功!',
- icon: 'success'
- });
- } else {
- uni.showToast({
- title: res.data.mess,
- icon: 'success'
- });
- }
- },
- /**
- * 查询用户
- */
- async selectUser(code) {
- const res = await this.$myRequest({
- host: this.ceshi,
- url: '/HotWaters/wpget_stu.action',
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- code: code
- }
- })
- // console.log(res);
- if (res.data.mess == '未查询到用户信息') {
- this.showPop = true
- }
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .container {
- display: flex;
- flex-direction: column;
- width: 750rpx;
- font-family: Microsoft YaHei-3970(82674968);
- color: #333333;
- .banner {
- width: 100%;
- height: 360rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .nav {
- position: relative;
- width: 100%;
- .menu,
- .reset {
- margin: 25rpx auto;
- width: 640rpx;
- }
- .menu_item {
- display: inline-flex;
- flex-direction: column;
- text-align: center;
- width: 25%;
- padding: 30rpx 0 39rpx;
- border-radius: 20rpx;
- font-family: Microsoft YaHei-3970(82674968);
- color: #333333;
- image {
- width: 90rpx;
- height: 90rpx;
- margin: 0 auto;
- }
- text {
- height: 29rpx;
- line-height: 54rpx;
- font-size: 30rpx;
- color: #333333;
- }
- }
- }
- .lineGroup {
- display: flex;
- flex-direction: row;
- border-bottom: 1px solid #c2c2c2;
- font-size: 38rpx;
- white-space: nowrap;
- <<<<<<< HEAD
- =======
-
- >>>>>>> 4380156aef5e8beb51c02d4586781d9ce0e14435
- .label-icon {
- display: flex;
- flex-direction: row;
- justify-items: right;
- align-items: center;
- font-size: 58rpx;
- width: 88rpx;
- height: 88rpx;
- line-height: 88rpx;
- color: $my-color-primary;
- margin: 22rpx 0 0 50rpx;
- }
- <<<<<<< HEAD
- =======
-
- >>>>>>> 4380156aef5e8beb51c02d4586781d9ce0e14435
- .stu-number {
- margin-top: 20rpx;
- color: #00c200;
- height: 88rpx;
- line-height: 88rpx;
- }
- }
- }
- </style>
|