agreePrivacy.js.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. mbos('page').bind('afterOnload', function () {
  2. var app = new Vue({
  3. el: '#app_privacy',
  4. data: {
  5. storeEid: mbos.pageInfo.storeEid,
  6. noDataUrl: '/mbos/store/' + mbos.pageInfo.storeEid + '/shrnewlightapp/no_data.png',
  7. hasAgreement: true,
  8. agreements: [],
  9. showRevoke: false, //显示撤回按钮
  10. isAllowRecallAgreement: false, //是否允许撤回隐私协议
  11. confirmRevoke: false
  12. },
  13. mounted: function () {
  14. const _this = this;
  15. setTimeout(() => {
  16. _this.getSignedAgreement();
  17. _this.getTheme();//获取个性化配置
  18. });
  19. $('#body').css('overflow', 'hidden');
  20. let agreementDom = $('.agreementContent');
  21. agreementDom.on('scroll', function() {
  22. let agreementDom = $('.agreementContent');
  23. let clientHeight = agreementDom[0].clientHeight;
  24. let scrollTop = agreementDom[0].scrollTop;
  25. let scrollHeight = agreementDom[0].scrollHeight;
  26. if(clientHeight + scrollTop == scrollHeight && _this.isAllowRecallAgreement) {
  27. _this.showRevoke = true;
  28. }else if(clientHeight + scrollTop > scrollHeight && _this.isAllowRecallAgreement){
  29. _this.showRevoke = true;
  30. }else{
  31. _this.showRevoke = false;
  32. }
  33. });
  34. },
  35. methods: {
  36. getSignedAgreement() {
  37. const _this = this;
  38. const param = ['getSignedAgreementService', JSON.stringify({})];
  39. mbos.eas.invokeScript({
  40. name: "commonOSFservice",
  41. param: param,
  42. success: function (resp) {
  43. if(resp.data.length > 0) {
  44. _this.hasAgreement = true;
  45. _this.agreements = resp.data;
  46. _this.getAgreementContent();
  47. }else{
  48. _this.hasAgreement = false;
  49. }
  50. },
  51. error: function () {
  52. _this.hasAgreement = false;
  53. },
  54. })
  55. },
  56. getAgreementContent() {
  57. const _this = this;
  58. const id = _this.agreements[0].id;
  59. const obj = {
  60. id: id,
  61. lang: easContext.locale
  62. };
  63. const param = ['getAgreementServiceByID', JSON.stringify(obj)];
  64. mbos.eas.invokeScript({
  65. name: "commonOSFservice",
  66. param: param,
  67. success: function (resp) {
  68. $('.agreementContent').empty();
  69. $('.agreementContent').append(resp.data.content);
  70. let agreementDom = $('.agreementContent');
  71. let clientHeight = agreementDom[0].clientHeight;
  72. let scrollTop = agreementDom[0].scrollTop;
  73. let scrollHeight = agreementDom[0].scrollHeight
  74. if(clientHeight + scrollTop == scrollHeight && _this.isAllowRecallAgreement) {
  75. _this.showRevoke = true;
  76. }else{
  77. _this.showRevoke = false;
  78. }
  79. },
  80. error: function () {
  81. },
  82. })
  83. },
  84. onItemClick(id) {
  85. const _this = this;
  86. $('.agreementContent').scrollTop(0);
  87. $('.privacy_title').each(function() {
  88. if($(this).hasClass('privacy_title_active')) {
  89. $(this).removeClass('privacy_title_active');
  90. }
  91. });
  92. $(event.target).addClass('privacy_title_active');
  93. const obj = {
  94. id: id,
  95. lang: easContext.locale
  96. };
  97. const param = ['getAgreementServiceByID', JSON.stringify(obj)];
  98. mbos.eas.invokeScript({
  99. name: "commonOSFservice",
  100. param: param,
  101. success: function (resp) {
  102. $('.agreementContent').empty();
  103. $('.agreementContent').append(resp.data.content);
  104. let agreementDom = $('.agreementContent');
  105. let clientHeight = agreementDom[0].clientHeight;
  106. let scrollTop = agreementDom[0].scrollTop;
  107. let scrollHeight = agreementDom[0].scrollHeight;
  108. if(clientHeight + scrollTop == scrollHeight && _this.isAllowRecallAgreement) {
  109. _this.showRevoke = true;
  110. }else{
  111. _this.showRevoke = false;
  112. }
  113. },
  114. error: function () {
  115. },
  116. })
  117. },
  118. /**
  119. * 签署声明
  120. * signState: 0:同意;1:撤回;2:拒绝
  121. */
  122. Agreement(){
  123. const _this = this;
  124. let id = $('.privacy_title_active').attr('id');
  125. let obj = {
  126. signPerson: easContext.userID,
  127. agreementIds: id,
  128. signState: 1
  129. };
  130. const param = ['signAgreementService', JSON.stringify(obj)];
  131. mbos.eas.invokeScript({
  132. name: 'commonOSFservice',
  133. needShowLoading: true,
  134. param: param,
  135. success: function(res){
  136. console.log(res,'sign');
  137. _this.confirmRevoke = false;
  138. _this.getSignedAgreement();
  139. },
  140. error: function(res){
  141. console.log(res)
  142. }
  143. })
  144. },
  145. //获取个性化配置
  146. getTheme() {
  147. const _this = this;
  148. const param = ['getThemeActionService', JSON.stringify({})];
  149. mbos.eas.invokeScript({
  150. name: 'commonOSFservice',
  151. needShowLoading: true,
  152. param: param,
  153. success: function(res){
  154. const config = JSON.parse(res.config);
  155. //config.isRecallAgreement == '1'
  156. if(config.isRecallAgreement != '2') {
  157. _this.isAllowRecallAgreement = true;
  158. }
  159. },
  160. error: function(res){
  161. console.log(res)
  162. }
  163. })
  164. },
  165. //确认是否撤回授权
  166. revokeConfirm() {
  167. const _this = this;
  168. _this.confirmRevoke = true;
  169. },
  170. //取消撤回
  171. cancelRevoke() {
  172. const _this = this;
  173. _this.confirmRevoke = false;
  174. }
  175. }
  176. })
  177. });