guhongwei 2 年之前
父节点
当前提交
ffa7713961
共有 6 个文件被更改,包括 40 次插入18 次删除
  1. 1 1
      pages/index/index.js
  2. 18 3
      pages/register/index.js
  3. 14 6
      pages/register/index.wxml
  4. 1 1
      pages/smy/index.js
  5. 5 6
      pages/suser/list.js
  6. 1 1
      utils/httpUtil.js

+ 1 - 1
pages/index/index.js

@@ -39,7 +39,7 @@ Page({
         })
     },
     async toLogin(openid) {
-        const res = await app.$post('/newCourt/api/user/wxAppLogin', { openid });
+        const res = await app.$post('/user/wxAppLogin', { openid });
         if (app.$checkRes(res)) {
             const { data } = res;
             // 没有用户,去注册

+ 18 - 3
pages/register/index.js

@@ -5,14 +5,19 @@ Page({
     data: {
         frameStyle: { useTop: true, name: '注册', leftArrow: false, useBar: false },
         form: { icon: [] },
+        // 用户类型
+        typeList: [
+            { label: '普通用户', value: '0' },
+            { label: '学员用户', value: '3' },
+        ],
         // 性别
         genderList: gender,
         agree: false
     },
     initValidate() {
-        const rules = { icon: { required: true }, name: { required: true }, card: { required: true }, gender: { required: true }, phone: { required: true, tel: true } }
+        const rules = { icon: { required: true }, name: { required: true }, gender: { required: true }, phone: { required: true, tel: true } }
         // 验证字段的提示信息,若不传则调用默认的信息
-        const messages = { icon: { required: '请选择头像', }, name: { required: '请输入用户姓名', }, card: { required: '请输入身份证号', }, gender: { required: '请选择性别', }, phone: { required: '请输入手机号', } };
+        const messages = { icon: { required: '请选择头像', }, name: { required: '请输入用户姓名', }, gender: { required: '请选择性别', }, phone: { required: '请输入手机号', } };
         this.WxValidate = new WxValidate(rules, messages)
     },
     imgUpl: function (e) {
@@ -34,6 +39,16 @@ Page({
         let data = that.data.genderList[e.detail.value];
         if (data) that.setData({ 'form.gender': data.value });
     },
+    // 选择用户类型
+    typeChange: function (e) {
+        const that = this;
+        let data = that.data.typeList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.type': data.value });
+            that.setData({ 'form.type_name': data.label });
+
+        }
+    },
     // 公共跳转
     toCommon: function (e) {
         // 登录
@@ -61,7 +76,7 @@ Page({
                 const wxInfo = app.globalData.wxInfo;
                 if (!wxInfo.openid) { wx.showToast({ title: '缺少微信关联', icon: 'error' }); return }
                 params.openid = wxInfo.openid;
-                const arr = await app.$post('/newCourt/api/user', params)
+                const arr = await app.$post('/user', params)
                 if (arr.errcode == '0') {
                     wx.showToast({ title: `注册成功`, icon: 'fail', duration: 2000 });
                     wx.redirectTo({ url: '/pages/index/index' });

+ 14 - 6
pages/register/index.wxml

@@ -14,12 +14,6 @@
                         <input type="text" name="name" value="{{form.name}}" placeholder="请输入姓名" />
                     </view>
                 </view>
-                <view class="content">
-                    <view class="label">身份证号:</view>
-                    <view class="value">
-                        <input type="text" name="card" value="{{form.card}}" placeholder="请输入身份证号" />
-                    </view>
-                </view>
                 <view class="content">
                     <view class="label">性别:</view>
                     <view class="value">
@@ -34,6 +28,20 @@
                         <input type="text" name="phone" value="{{form.phone}}" placeholder="请输入手机号" />
                     </view>
                 </view>
+                <view class="content">
+                    <view class="label">用户类型:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="typeChange" name="type" value="{{form.type}}" range="{{typeList}}" range-key="label">
+                            <view class="picker">{{form.type_name||'请选择用户类型'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content" wx:if="{{form.type=='3'}}">
+                    <view class="label">用户类型:</view>
+                    <view class="value">
+                        <input type="text" name="card" value="{{form.card}}" placeholder="请输入身份证号" />
+                    </view>
+                </view>
                 <view class="btn">
                     <button type="primary" size="mini" formType="submit">提交注册</button>
                     <button type="warn" size="mini">游客登录</button>

+ 1 - 1
pages/smy/index.js

@@ -42,7 +42,7 @@ Page({
         wx.getStorage({
             key: 'user',
             success: async res => {
-                const arr = await app.$get(`/newCourt/api/user/${res.data._id}`);
+                const arr = await app.$get(`/user/${res.data._id}`);
                 if (arr.errcode == '0') {
                     that.setData({ user: arr.data })
                     let btnData = school_menu.find((i) => i.type == arr.data.type);

+ 5 - 6
pages/suser/list.js

@@ -62,12 +62,11 @@ Page({
             key: 'user',
             success: async res => {
                 const arr = await app.$get(`/newCourt/api/user`);
-                console.log(arr);
-                // if (arr.errcode == '0') {
-                //     for (const val of arr.data) { val.zHtype = this.searchType(val.type) }
-                //     that.setData({ list: arr.data });
-                // }
-                // else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
+                if (arr.errcode == '0') {
+                    for (const val of arr.data) { val.zHtype = this.searchType(val.type) }
+                    that.setData({ list: arr.data });
+                }
+                else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
             },
             fail: async res => {
                 wx.redirectTo({ url: '/pages/index/index' })

+ 1 - 1
utils/httpUtil.js

@@ -3,7 +3,7 @@ let wechatUrl = 'https://broadcast.waityou24.cn';
 
 const getDomain = (uri) => {
     if (uri.startsWith('/wechat/api')) return wechatUrl;
-    return serverUrl;
+    return serverUrl+'/newCourt/v2/api';
 }
 
 const $get = (uri, data) => {