my-popup-zhifu.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <view class="uni-popup-dialog">
  3. <view class="uni-dialog-title">
  4. <text class="uni-dialog-title-text uni-popup__dialog">{{titleText}}</text>
  5. </view>
  6. <view v-if="mode === 'base'" class="uni-dialog-content">
  7. <slot>
  8. <text class="uni-dialog-content-text">{{content}}</text>
  9. </slot>
  10. </view>
  11. <view v-else class="uni-dialog-content-input">
  12. <slot>
  13. <view style="width: 100%;font-size: 28rpx;">
  14. <view class="contentInRowS">
  15. <text>{{$t('tixian.jiner')}}</text>
  16. <text>{{$formPr(jiner)}}{{$t('api.huobidanwei')}}</text>
  17. </view>
  18. <!-- <view class="contentInRowS">
  19. <text>手续费</text>
  20. <text>¥{{yongjin}}</text>
  21. </view>
  22. <view class="contentInRowS">
  23. <text>到账金额</text>
  24. <text style="font-size: 32rpx;color: crimson;">¥{{daozhangjine}}</text>
  25. </view> -->
  26. </view>
  27. </slot>
  28. <slot>
  29. <input class="uni-dialog-input" v-model="val" :type="inputType" :placeholder="placeholderText" :focus="focus" :password="true">
  30. </slot>
  31. </view>
  32. <view class="uni-dialog-button-group">
  33. <view class="uni-dialog-button" @click="closeDialog">
  34. <text class="uni-dialog-button-text">{{$t('index.quxiao')}}</text>
  35. </view>
  36. <view class="uni-dialog-button uni-border-left" @click="onOk">
  37. <text class="uni-dialog-button-text uni-button-color">{{$t('index.queren')}}</text>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import popup from '../uni-popup/popup.js'
  44. import {
  45. initVueI18n
  46. } from '@dcloudio/uni-i18n'
  47. import messages from '../uni-popup/i18n/index.js'
  48. const { t } = initVueI18n(messages)
  49. /**
  50. * PopUp 弹出层-对话框样式
  51. * @description 弹出层-对话框样式
  52. * @tutorial https://ext.dcloud.net.cn/plugin?id=329
  53. * @property {String} value input 模式下的默认值
  54. * @property {String} placeholder input 模式下输入提示
  55. * * @property {String} placeholder2 2input 模式下输入提示
  56. * @property {String} type = [success|warning|info|error] 主题样式
  57. * @value success 成功
  58. * @value warning 提示
  59. * @value info 消息
  60. * @value error 错误
  61. * @property {String} mode = [base|input] 模式、
  62. * @value base 基础对话框
  63. * @value input 可输入对话框
  64. * @property {String} content 对话框内容
  65. * @property {Boolean} beforeClose 是否拦截取消事件
  66. * @event {Function} confirm 点击确认按钮触发
  67. * @event {Function} close 点击取消按钮触发
  68. */
  69. export default {
  70. name: "myPopupDialog",
  71. mixins: [popup],
  72. emits:['confirm','close'],
  73. props: {
  74. inputType:{
  75. type: String,
  76. default: 'text'
  77. },
  78. value: {
  79. type: [String, Number],
  80. default: ''
  81. },
  82. placeholder: {
  83. type: [String, Number],
  84. default: ''
  85. },
  86. placeholder2: {
  87. type: [String, Number],
  88. default: ''
  89. },
  90. type: {
  91. type: String,
  92. default: 'error'
  93. },
  94. mode: {
  95. type: String,
  96. default: 'base'
  97. },
  98. popmode: {
  99. type: Number,
  100. default: 2
  101. },
  102. title: {
  103. type: String,
  104. default: ''
  105. },
  106. jiner:{
  107. type: Number,
  108. default: 0
  109. },
  110. yongjin:{
  111. type: Number,
  112. default: 0
  113. },
  114. daozhangjine:{
  115. type: Number,
  116. default: 0
  117. },
  118. content: {
  119. type: String,
  120. default: ''
  121. },
  122. beforeClose: {
  123. type: Boolean,
  124. default: false
  125. },
  126. cancelText:{
  127. type: String,
  128. default: ''
  129. },
  130. confirmText:{
  131. type: String,
  132. default: ''
  133. }
  134. },
  135. data() {
  136. return {
  137. dialogType: 'error',
  138. focus: false,
  139. val: "",
  140. val2: "",
  141. radioV:'1',
  142. radioV2:'1'
  143. }
  144. },
  145. computed: {
  146. okText() {
  147. return this.confirmText || t("uni-popup.ok")
  148. },
  149. closeText() {
  150. return this.cancelText || t("uni-popup.cancel")
  151. },
  152. placeholderText() {
  153. return this.placeholder || t("uni-popup.placeholder")
  154. },
  155. placeholderText2() {
  156. return this.placeholder2 || t("uni-popup.placeholder")
  157. },
  158. titleText() {
  159. return this.title || t("uni-popup.title")
  160. }
  161. },
  162. watch: {
  163. type(val) {
  164. this.dialogType = val
  165. },
  166. mode(val) {
  167. if (val === 'input') {
  168. this.dialogType = 'info'
  169. }
  170. }
  171. // value(val) {
  172. // this.val = val
  173. // }
  174. },
  175. created() {
  176. // 对话框遮罩不可点击
  177. this.popup.disableMask()
  178. // this.popup.closeMask()
  179. if (this.mode === 'input') {
  180. this.dialogType = 'info'
  181. //this.val = this.value
  182. } else {
  183. this.dialogType = this.type
  184. }
  185. },
  186. mounted() {
  187. this.focus = true
  188. },
  189. methods: {
  190. radioChange(evt){
  191. this.radioV = evt.detail.value
  192. },
  193. radioChange2(evt){
  194. this.radioV2 = evt.detail.value
  195. },
  196. input2(event){
  197. this.val2 = event.target.value;
  198. },
  199. input(event){
  200. this.val = event.target.value;
  201. },
  202. /**
  203. * 点击确认按钮
  204. */
  205. onOk() {
  206. if (this.mode === 'input'){
  207. this.$emit('confirm', this.val,this.val2,this.radioV,this.radioV2)
  208. }else{
  209. this.$emit('confirm')
  210. }
  211. if(this.beforeClose) return
  212. this.popup.close()
  213. },
  214. /**
  215. * 点击取消按钮
  216. */
  217. closeDialog() {
  218. this.$emit('close')
  219. if(this.beforeClose) return
  220. this.popup.close()
  221. },
  222. close(){
  223. this.popup.close()
  224. }
  225. }
  226. }
  227. </script>
  228. <style lang="scss" >
  229. .uni-popup-dialog {
  230. width: 300px;
  231. border-radius: 11px;
  232. background-color: #fff;
  233. }
  234. .uni-dialog-title {
  235. /* #ifndef APP-NVUE */
  236. display: flex;
  237. /* #endif */
  238. flex-direction: row;
  239. justify-content: center;
  240. padding-top: 25rpx;
  241. border-bottom-color: #f5f5f5;
  242. border-bottom-style: solid;
  243. border-bottom-width: 1px;
  244. }
  245. .uni-dialog-title-text {
  246. font-size: 16px;
  247. font-weight: 500;
  248. }
  249. .uni-dialog-content {
  250. /* #ifndef APP-NVUE */
  251. display: flex;
  252. /* #endif */
  253. flex-direction: row;
  254. justify-content: center;
  255. align-items: center;
  256. // padding: 20px;
  257. }
  258. .uni-dialog-content-input {
  259. /* #ifndef APP-NVUE */
  260. display: flex;
  261. /* #endif */
  262. flex-direction: column;
  263. justify-content: center;
  264. align-items: center;
  265. padding-left: 20px;
  266. padding-right: 20px;
  267. padding-top: 10rpx;
  268. }
  269. .uni-dialog-content-text {
  270. font-size: 14px;
  271. color: #6C6C6C;
  272. }
  273. .uni-dialog-button-group {
  274. /* #ifndef APP-NVUE */
  275. display: flex;
  276. /* #endif */
  277. flex-direction: row;
  278. border-top-color: #f5f5f5;
  279. border-top-style: solid;
  280. border-top-width: 1px;
  281. }
  282. .uni-dialog-button {
  283. /* #ifndef APP-NVUE */
  284. display: flex;
  285. /* #endif */
  286. flex: 1;
  287. flex-direction: row;
  288. justify-content: center;
  289. align-items: center;
  290. height: 45px;
  291. }
  292. .contentInRowS{
  293. display: flex;
  294. flex-direction: row;
  295. align-items: center;
  296. justify-content: space-between;
  297. }
  298. .uni-border-left {
  299. border-left-color: #f0f0f0;
  300. border-left-style: solid;
  301. border-left-width: 1px;
  302. }
  303. .uni-dialog-button-text {
  304. font-size: 16px;
  305. color: #333;
  306. }
  307. .uni-button-color {
  308. color: #007aff;
  309. }
  310. .uni-dialog-input {
  311. width: 100%;
  312. flex: 1;
  313. font-size: 14px;
  314. border: 1px #eee solid;
  315. height: 40px;
  316. padding: 0 10px;
  317. border-radius: 5px;
  318. color: #555;
  319. margin: 20rpx;
  320. }
  321. .uni-popup__success {
  322. color: #4cd964;
  323. }
  324. .uni-popup__warn {
  325. color: #f0ad4e;
  326. }
  327. .uni-popup__error {
  328. color: #dd524d;
  329. }
  330. .uni-popup__info {
  331. color: #909399;
  332. }
  333. .uni-popup__dialog {
  334. color: #1A1A1A;
  335. }
  336. </style>