uni-popup-dialog-wx-auth.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="uni-popup-dialog">
  3. <view class="wx-auth">
  4. <view class="logo-box">
  5. <image style="width: 100%;height: 100%;border-radius: 50%;" src="../../static/wx-share.png" mode=""></image>
  6. </view>
  7. <view class="close-box">
  8. <image style="width: 100%;height: 100%;border-radius: 50%;" @click="close" src="../../static/wx-cancel.png" mode=""></image>
  9. </view>
  10. <view class="content-box">
  11. <view class="title">
  12. 微信授权
  13. </view>
  14. <view class="content">
  15. 获取您的微信头像、昵称信息。
  16. </view>
  17. <!-- <button class="auth-btn" @getuserinfo="onOk" open-type="getUserInfo">同意授权</button> -->
  18. <button class="auth-btn" @click="onOk" >同意授权</button>
  19. </view>
  20. </view>
  21. <!-- <view class="uni-dialog-button-group">
  22. <view class="uni-dialog-button" @click="close">
  23. <text class="uni-dialog-button-text">取消</text>
  24. </view>
  25. <view class="uni-dialog-button uni-border-left" @click="onOk">
  26. <text class="uni-dialog-button-text uni-button-color">确定</text>
  27. </view>
  28. </view> -->
  29. </view>
  30. </template>
  31. <script>
  32. /**
  33. * PopUp 弹出层-对话框样式
  34. * @description 弹出层-对话框样式
  35. * @tutorial https://ext.dcloud.net.cn/plugin?id=329
  36. * @property {String} value input 模式下的默认值
  37. * @property {String} placeholder input 模式下输入提示
  38. * @property {String} type = [success|warning|info|error] 主题样式
  39. * @value success 成功
  40. * @value warning 提示
  41. * @value info 消息
  42. * @value error 错误
  43. * @property {String} mode = [base|input] 模式、
  44. * @value base 基础对话框
  45. * @value input 可输入对话框
  46. * @property {String} content 对话框内容
  47. * @property {Boolean} beforeClose 是否拦截取消事件
  48. * @event {Function} confirm 点击确认按钮触发
  49. * @event {Function} close 点击取消按钮触发
  50. */
  51. export default {
  52. name: "uniPopupDialog",
  53. props: {
  54. value: {
  55. type: [String, Number],
  56. default: ''
  57. },
  58. placeholder: {
  59. type: [String, Number],
  60. default: '请输入内容'
  61. },
  62. /**
  63. * 对话框主题 success/warning/info/error 默认 success
  64. */
  65. type: {
  66. type: String,
  67. default: 'error'
  68. },
  69. /**
  70. * 对话框模式 base/input
  71. */
  72. mode: {
  73. type: String,
  74. default: 'base'
  75. },
  76. /**
  77. * 对话框标题
  78. */
  79. title: {
  80. type: String,
  81. default: '提示'
  82. },
  83. /**
  84. * 对话框内容
  85. */
  86. content: {
  87. type: String,
  88. default: ''
  89. },
  90. /**
  91. * 拦截取消事件 ,如果拦截取消事件,必须监听close事件,执行 done()
  92. */
  93. beforeClose: {
  94. type: Boolean,
  95. default: false
  96. }
  97. },
  98. data() {
  99. return {
  100. dialogType: 'error',
  101. focus: false,
  102. val: ""
  103. }
  104. },
  105. inject: ['popup'],
  106. watch: {
  107. type(val) {
  108. this.dialogType = val
  109. },
  110. mode(val) {
  111. if (val === 'input') {
  112. this.dialogType = 'info'
  113. }
  114. },
  115. value(val) {
  116. this.val = val
  117. }
  118. },
  119. created() {
  120. // 对话框遮罩不可点击
  121. this.popup.mkclick = false
  122. if (this.mode === 'input') {
  123. this.dialogType = 'info'
  124. this.val = this.value
  125. } else {
  126. this.dialogType = this.type
  127. }
  128. },
  129. mounted() {
  130. this.focus = true
  131. },
  132. methods: {
  133. /**
  134. * 点击确认按钮
  135. */
  136. onOk(e) {
  137. // console.log('onOk ' + JSON.stringify(e))
  138. this.$emit('confirm', () => {
  139. this.popup.close()
  140. if (this.mode === 'input') this.val = this.value
  141. }, e)// 注意最后这个参数e要传到前端
  142. },
  143. /**
  144. * 点击取消按钮
  145. */
  146. close() {
  147. if (this.beforeClose) {
  148. this.$emit('close', () => {
  149. this.popup.close()
  150. })
  151. return
  152. }
  153. this.popup.close()
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. .uni-popup-dialog {
  160. // width: 300px;
  161. // border-radius: 15px;
  162. // background-color: #fff;
  163. }
  164. .uni-dialog-title {
  165. /* #ifndef APP-NVUE */
  166. display: flex;
  167. /* #endif */
  168. flex-direction: row;
  169. justify-content: center;
  170. padding-top: 15px;
  171. padding-bottom: 5px;
  172. }
  173. .uni-dialog-title-text {
  174. font-size: 16px;
  175. font-weight: 500;
  176. }
  177. .uni-dialog-content {
  178. /* #ifndef APP-NVUE */
  179. display: flex;
  180. /* #endif */
  181. flex-direction: row;
  182. justify-content: center;
  183. align-items: center;
  184. padding: 5px 15px 15px 15px;
  185. font-size: 32rpx;
  186. }
  187. .uni-dialog-content-text {
  188. font-size: 14px;
  189. color: #6e6e6e;
  190. }
  191. .uni-dialog-button-group {
  192. /* #ifndef APP-NVUE */
  193. display: flex;
  194. /* #endif */
  195. flex-direction: row;
  196. border-top-color: #f5f5f5;
  197. border-top-style: solid;
  198. border-top-width: 1px;
  199. }
  200. .uni-dialog-button {
  201. /* #ifndef APP-NVUE */
  202. display: flex;
  203. /* #endif */
  204. flex: 1;
  205. flex-direction: row;
  206. justify-content: center;
  207. align-items: center;
  208. height: 45px;
  209. }
  210. .uni-border-left {
  211. border-left-color: #f0f0f0;
  212. border-left-style: solid;
  213. border-left-width: 1px;
  214. }
  215. .uni-dialog-button-text {
  216. font-size: 14px;
  217. }
  218. .uni-button-color {
  219. color: $uni-color-primary;
  220. }
  221. .uni-dialog-input {
  222. flex: 1;
  223. font-size: 14px;
  224. }
  225. .uni-popup__success {
  226. color: $uni-color-success;
  227. }
  228. .uni-popup__warn {
  229. color: $uni-color-warning;
  230. }
  231. .uni-popup__error {
  232. color: $uni-color-error;
  233. }
  234. .uni-popup__info {
  235. color: #909399;
  236. }
  237. </style>
  238. <style lang="scss" scoped>
  239. .wx-auth{
  240. width: 500rpx;
  241. height: 300rpx;
  242. border-radius: 15rpx;
  243. background-color: #ffffff;
  244. position: relative;
  245. padding: 0 40rpx;
  246. .logo-box{
  247. width: 100rpx;
  248. height: 100rpx;
  249. background-color: #ffffff;
  250. border: 5rpx solid #dedede;
  251. border-radius: 50%;
  252. position: absolute;
  253. top: -15%;
  254. left: 50%;
  255. transform: translateX(-50%);
  256. }
  257. .close-box{
  258. width: 50rpx;
  259. height: 50rpx;
  260. position: absolute;
  261. right:-20rpx;
  262. top: -20rpx;
  263. background-color: #FFFFFF;
  264. border-radius: 50%;
  265. }
  266. .content-box{
  267. padding-top: 70rpx;
  268. display: flex;
  269. flex-direction: column;
  270. align-items: center;
  271. }
  272. .title{
  273. color: #333333;
  274. }
  275. .content{
  276. color: #999999;
  277. align-self: center;
  278. padding-top: 20rpx;
  279. font-size: 28rpx;
  280. }
  281. .auth-btn{
  282. margin-top: 30rpx;
  283. background-color: #0284c2;
  284. width: 50%;
  285. height: 70rpx;
  286. line-height: 70rpx;
  287. text-align: center;
  288. color: #FFFFFF;
  289. font-size: 30rpx;
  290. border-radius: 15rpx;
  291. }
  292. }
  293. </style>