mbos('page').bind('afterOnload', function () { var app = new Vue({ el: '#app_privacy', data: { storeEid: mbos.pageInfo.storeEid, noDataUrl: '/mbos/store/' + mbos.pageInfo.storeEid + '/shrnewlightapp/no_data.png', hasAgreement: true, agreements: [], showRevoke: false, //显示撤回按钮 isAllowRecallAgreement: false, //是否允许撤回隐私协议 confirmRevoke: false }, mounted: function () { const _this = this; setTimeout(() => { _this.getSignedAgreement(); _this.getTheme();//获取个性化配置 }); $('#body').css('overflow', 'hidden'); let agreementDom = $('.agreementContent'); agreementDom.on('scroll', function() { let agreementDom = $('.agreementContent'); let clientHeight = agreementDom[0].clientHeight; let scrollTop = agreementDom[0].scrollTop; let scrollHeight = agreementDom[0].scrollHeight; if(clientHeight + scrollTop == scrollHeight && _this.isAllowRecallAgreement) { _this.showRevoke = true; }else if(clientHeight + scrollTop > scrollHeight && _this.isAllowRecallAgreement){ _this.showRevoke = true; }else{ _this.showRevoke = false; } }); }, methods: { getSignedAgreement() { const _this = this; const param = ['getSignedAgreementService', JSON.stringify({})]; mbos.eas.invokeScript({ name: "commonOSFservice", param: param, success: function (resp) { if(resp.data.length > 0) { _this.hasAgreement = true; _this.agreements = resp.data; _this.getAgreementContent(); }else{ _this.hasAgreement = false; } }, error: function () { _this.hasAgreement = false; }, }) }, getAgreementContent() { const _this = this; const id = _this.agreements[0].id; const obj = { id: id, lang: easContext.locale }; const param = ['getAgreementServiceByID', JSON.stringify(obj)]; mbos.eas.invokeScript({ name: "commonOSFservice", param: param, success: function (resp) { $('.agreementContent').empty(); $('.agreementContent').append(resp.data.content); let agreementDom = $('.agreementContent'); let clientHeight = agreementDom[0].clientHeight; let scrollTop = agreementDom[0].scrollTop; let scrollHeight = agreementDom[0].scrollHeight if(clientHeight + scrollTop == scrollHeight && _this.isAllowRecallAgreement) { _this.showRevoke = true; }else{ _this.showRevoke = false; } }, error: function () { }, }) }, onItemClick(id) { const _this = this; $('.agreementContent').scrollTop(0); $('.privacy_title').each(function() { if($(this).hasClass('privacy_title_active')) { $(this).removeClass('privacy_title_active'); } }); $(event.target).addClass('privacy_title_active'); const obj = { id: id, lang: easContext.locale }; const param = ['getAgreementServiceByID', JSON.stringify(obj)]; mbos.eas.invokeScript({ name: "commonOSFservice", param: param, success: function (resp) { $('.agreementContent').empty(); $('.agreementContent').append(resp.data.content); let agreementDom = $('.agreementContent'); let clientHeight = agreementDom[0].clientHeight; let scrollTop = agreementDom[0].scrollTop; let scrollHeight = agreementDom[0].scrollHeight; if(clientHeight + scrollTop == scrollHeight && _this.isAllowRecallAgreement) { _this.showRevoke = true; }else{ _this.showRevoke = false; } }, error: function () { }, }) }, /** * 签署声明 * signState: 0:同意;1:撤回;2:拒绝 */ Agreement(){ const _this = this; let id = $('.privacy_title_active').attr('id'); let obj = { signPerson: easContext.userID, agreementIds: id, signState: 1 }; const param = ['signAgreementService', JSON.stringify(obj)]; mbos.eas.invokeScript({ name: 'commonOSFservice', needShowLoading: true, param: param, success: function(res){ console.log(res,'sign'); _this.confirmRevoke = false; _this.getSignedAgreement(); }, error: function(res){ console.log(res) } }) }, //获取个性化配置 getTheme() { const _this = this; const param = ['getThemeActionService', JSON.stringify({})]; mbos.eas.invokeScript({ name: 'commonOSFservice', needShowLoading: true, param: param, success: function(res){ const config = JSON.parse(res.config); //config.isRecallAgreement == '1' if(config.isRecallAgreement != '2') { _this.isAllowRecallAgreement = true; } }, error: function(res){ console.log(res) } }) }, //确认是否撤回授权 revokeConfirm() { const _this = this; _this.confirmRevoke = true; }, //取消撤回 cancelRevoke() { const _this = this; _this.confirmRevoke = false; } } }) });