Browse Source

添加协议

lex 2 years ago
parent
commit
b99136f6fc

+ 22 - 3
src/views/order-detail/index.tsx

@@ -44,7 +44,8 @@ export default defineComponent({
       paymentStatus: false,
       orderAmount: 0, // 订单金额,用于使用优惠券,余额,优惠等
       orderPrice: 0, // 支付金额,最后支付金额
-      dataLoading: true
+      dataLoading: true,
+      exists: false // 是否签署过用户注册协议
     }
   },
   unmounted() {
@@ -63,6 +64,7 @@ export default defineComponent({
     }
   },
   async mounted() {
+    await this.getUserRegisterProtocol()
     // 判断是否是曲目购买(只有智能陪练才会有入口),其它地方不会有入口
     this.dataLoading = true
     if (this.orderType == 'MUSIC' && this.id) {
@@ -104,8 +106,25 @@ export default defineComponent({
     }
   },
   methods: {
-    onAuthSuccess() {
+    async getUserRegisterProtocol() {
+      // 获取是否签署过《用户注册协议》
+      try {
+        const res = await request.get(
+          state.platformApi + '/sysUserContractRecord/checkContractSign',
+          {
+            params: {
+              contractType: 'REGISTER'
+            }
+          }
+        )
+        this.exists = res.data
+      } catch {
+        //
+      }
+    },
+    async onAuthSuccess() {
       this.popupShow = false
+      await this.getUserRegisterProtocol()
       this.onSubmit() // 实名成功后自动支付
     },
     async onSubmit() {
@@ -290,7 +309,7 @@ export default defineComponent({
           </>
         )}
         <ColPopup v-model={this.popupShow}>
-          <UserAuth onSuccess={this.onAuthSuccess} />
+          <UserAuth exists={this.exists} onSuccess={this.onAuthSuccess} />
         </ColPopup>
 
         <Popup

+ 35 - 0
src/views/order-detail/userAuth/index.module.less

@@ -7,4 +7,39 @@
     padding: 0 14px;
     padding-bottom: 15px;
   }
+
+  .colProtocol {
+    // display: flex;
+    // align-items: center;
+    font-size: 12px;
+    padding: 15px 14px;
+    color: #999;
+    .protocolText {
+      color: var(--van-primary);
+      line-height: 15px;
+    }
+
+    .boxStyle {
+      background: transparent !important;
+      width: 15px;
+      height: 15px;
+      border: transparent !important;
+    }
+    :global {
+      .van-checkbox {
+        display: inline-block;
+        align-items: inherit;
+        overflow: inherit;
+      }
+      .van-checkbox__icon {
+        height: 15px;
+        line-height: 15px;
+        display: inline-block;
+        vertical-align: middle;
+      }
+      .van-checkbox__label {
+        line-height: 15px;
+      }
+    }
+  }
 }

+ 51 - 3
src/views/order-detail/userAuth/index.tsx

@@ -4,8 +4,10 @@ import ColHeader from '@/components/col-header'
 import request from '@/helpers/request'
 import { verifyIdCard } from '@/helpers/toolsValidate'
 import { state } from '@/state'
-import { Button, CellGroup, Field, Form, Toast } from 'vant'
+import { Button, CellGroup, Checkbox, Field, Form, Icon, Toast } from 'vant'
 import { defineComponent } from 'vue'
+import activeButtonIcon from '@common/images/icon_checkbox.png'
+import inactiveButtonIcon from '@common/images/icon_checkbox_default.png'
 import styles from './index.module.less'
 
 export default defineComponent({
@@ -15,6 +17,10 @@ export default defineComponent({
       // 实名成功
       type: Function,
       default: () => {}
+    },
+    exists: {
+      type: Boolean,
+      default: false
     }
   },
   data() {
@@ -22,12 +28,21 @@ export default defineComponent({
       form: {
         realName: '',
         idCardNo: ''
-      }
+      },
+      checked: false
     }
   },
+  mounted() {
+    // exists
+    this.checked = this.checked || this.exists
+  },
   methods: {
     async onSubmit() {
       try {
+        if (!this.checked) {
+          Toast('请先阅读并同意《用户注册协议》')
+          return
+        }
         await request.post('/api-auth/user/realNameAuth', {
           data: {
             ...this.form,
@@ -41,6 +56,18 @@ export default defineComponent({
           this.onSuccess()
         }, 500)
       } catch {}
+    },
+    getContractDetail() {
+      // 查看协议
+      const client = state.platformType === 'STUDENT' ? 'student' : 'teacher'
+      postMessage({
+        api: 'openWebView',
+        content: {
+          url: `${location.origin}/${client}/#/previewProtocol`,
+          orientation: 1,
+          isHideTitle: false
+        }
+      })
     }
   },
   render() {
@@ -73,7 +100,28 @@ export default defineComponent({
             />
           </ColField>
         </ColFieldGroup>
-
+        <div class={styles.colProtocol}>
+          {!this.exists && (
+            <Checkbox
+              v-model={this.checked}
+              v-slots={{
+                icon: (props: any) => (
+                  <Icon
+                    class={styles.boxStyle}
+                    name={props.checked ? activeButtonIcon : inactiveButtonIcon}
+                    size="15"
+                  />
+                )
+              }}
+            >
+              我已阅读并同意
+            </Checkbox>
+          )}
+          {this.exists && <>查看</>}
+          <span onClick={this.getContractDetail} class={styles.protocolText}>
+            《用户注册协议》
+          </span>
+        </div>
         <div class={['btnGroup']}>
           <Button block round type="primary" native-type="submit">
             确定