editMemberbankcard.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <view v-if="is_submitaudit!=1" class="container">
  3. <tui-tabs :top="0" :tabs="ptypeTabs" :height="88" :currentTab="currentPtype" :sliderWidth="300"
  4. :sliderHeight="60" itemWidth="50%" bottom="50%" color="#888" selectedColor="#5677fc" :bold="true"
  5. sliderBgColor="#E5FAFF" @change="ptypechange">
  6. </tui-tabs>
  7. <view class="tui-addr-box">
  8. <form @submit="bindSave" :report-submit="true">
  9. <tui-list-cell :hover="false" padding="0">
  10. <view class="tui-line-cell">
  11. <view class="tui-title">姓名</view>
  12. <input placeholder-class="tui-phcolor" class="tui-input" name="name"
  13. :value="memberbankcardData.name" placeholder="请输入收款姓名" type="text" />
  14. </view>
  15. </tui-list-cell>
  16. <tui-list-cell v-if="ptype==1 || ptype==2" :hover="false" padding="0">
  17. <view class="tui-line-cell">
  18. <view class="tui-title">帐号</view>
  19. <input placeholder-class="tui-phcolor" class="tui-input" name="accounts"
  20. :value="memberbankcardData.accounts" placeholder="请输入帐号" type="text" />
  21. </view>
  22. </tui-list-cell>
  23. <tui-list-cell v-if="ptype==3" :hover="false" padding="0">
  24. <view class="tui-line-cell">
  25. <view class="tui-title">手机/微信号</view>
  26. <input placeholder-class="tui-phcolor" class="tui-input" name="accounts"
  27. :value="memberbankcardData.accounts" placeholder="请输入手机号/微信号" type="text" />
  28. </view>
  29. </tui-list-cell>
  30. <tui-list-cell v-if="ptype==1" :hover="false" padding="0">
  31. <view class="tui-line-cell">
  32. <view class="tui-title">银行名称</view>
  33. <input placeholder-class="tui-phcolor" class="tui-input" name="bankname"
  34. :value="memberbankcardData.bankname" placeholder="请输入银行" type="text" />
  35. </view>
  36. </tui-list-cell>
  37. <tui-list-cell v-if="ptype==1" :hover="false" padding="0">
  38. <view class="tui-line-cell">
  39. <view class="tui-title">开户行</view>
  40. <input placeholder-class="tui-phcolor" class="tui-input" name="branchname"
  41. :value="memberbankcardData.branchname" placeholder="请输入开户行" type="text" />
  42. </view>
  43. </tui-list-cell>
  44. <!-- 保存帐号 -->
  45. <view class="tui-addr-save">
  46. <tui-button formType="submit" shadow type="danger" height="88rpx" shape="circle">保存帐号</tui-button>
  47. </view>
  48. <view class="tui-del" v-if="memberbankcardData.length > 0">
  49. <tui-button shadow type="gray" @click="deleteMemberbankcard" height="88rpx" shape="circle">删除帐号
  50. </tui-button>
  51. </view>
  52. </form>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. id: 0,
  61. is_submitaudit: 1,
  62. memberbankcardData: [],
  63. currentPtype: 0,
  64. ptype: 1,
  65. ptypeTabs: [{
  66. name: "银行卡"
  67. }, {
  68. name: "支付宝"
  69. }, {
  70. name: "微信支付"
  71. }]
  72. }
  73. },
  74. onLoad(e) {
  75. const _this = this;
  76. _this.$request.post('Config.audit', {
  77. samkey: (new Date()).valueOf()
  78. }).then(res => {
  79. _this.is_submitaudit = res.data.is_submitaudit;
  80. if (_this.is_submitaudit == 1) {
  81. uni.setNavigationBarTitle({
  82. title: "."
  83. });
  84. }
  85. });
  86. if (e.id) { // 修改初始化数据库数据
  87. _this.$request.get('memberbankcard.detail', {
  88. id: e.id,
  89. samkey: (new Date()).valueOf()
  90. }).then(res => {
  91. if (res.errno === 0) {
  92. _this.id = e.id;
  93. _this.memberbankcardData = res.data;
  94. _this.ptype = _this.memberbankcardData.ptype;
  95. _this.currentPtype = _this.ptype - 1;
  96. return;
  97. } else {
  98. uni.showModal({
  99. title: '提示',
  100. content: '无法获取帐号数据',
  101. showCancel: false
  102. })
  103. }
  104. })
  105. }
  106. },
  107. methods: {
  108. getcollecttype: function() {
  109. let _this = this
  110. _this.$request.get('memberbankcard.collecttype', {
  111. samkey: (new Date()).valueOf(),
  112. }).then(res => {
  113. if (res.errno == 0) {
  114. _this.statusType = res.data;
  115. _this.orderStatus = _this.statusType[_this.currentTab].id;
  116. }
  117. })
  118. },
  119. ptypechange: function(e) {
  120. console.log(e);
  121. this.currentPtype = e.index
  122. this.ptype = this.currentPtype + 1;
  123. },
  124. bindSave: function(e) {
  125. var _this = this;
  126. var name = e.detail.value.name;
  127. var accounts = e.detail.value.accounts;
  128. var bankname = e.detail.value.bankname;
  129. var branchname = e.detail.value.branchname;
  130. if (_this.ptype == 2) {
  131. bankname = '支付宝';
  132. }
  133. if (_this.ptype == 3) {
  134. bankname = '微信支付';
  135. }
  136. if (name == "") {
  137. uni.showModal({
  138. title: '提示',
  139. content: '请填写联系人姓名',
  140. showCancel: false
  141. })
  142. return
  143. }
  144. if (accounts == "") {
  145. uni.showModal({
  146. title: '提示',
  147. content: '请填写帐号',
  148. showCancel: false
  149. })
  150. return
  151. }
  152. if (bankname == "") {
  153. uni.showModal({
  154. title: '提示',
  155. content: '请填写银行',
  156. showCancel: false
  157. })
  158. return
  159. }
  160. let apiResult
  161. if (_this.id) {
  162. apiResult = _this.$request.post('memberbankcard.update', {
  163. id: _this.id,
  164. name: name,
  165. ptype: _this.ptype,
  166. accounts: accounts,
  167. bankname: bankname,
  168. branchname: branchname
  169. })
  170. } else {
  171. apiResult = _this.$request.post('memberbankcard.add', {
  172. name: name,
  173. ptype: _this.ptype,
  174. accounts: accounts,
  175. bankname: bankname,
  176. branchname: branchname,
  177. isDefault: '0'
  178. })
  179. }
  180. apiResult.then(function(res) {
  181. if (res.errno != 0) {
  182. // 登录错误
  183. uni.hideLoading();
  184. uni.showModal({
  185. title: '失败',
  186. content: res.msg,
  187. showCancel: false
  188. })
  189. return;
  190. }
  191. // 跳转到上一页
  192. uni.navigateBack({})
  193. })
  194. },
  195. deleteMemberbankcard: function() {
  196. var _this = this;
  197. var id = _this.memberbankcardData.id;
  198. uni.showModal({
  199. title: '提示',
  200. content: '确定要删除吗?',
  201. success: function(res) {
  202. if (res.confirm) {
  203. _this.$request.post('memberbankcard.delete', {
  204. id: id
  205. }).then(function() {
  206. uni.navigateBack({})
  207. })
  208. } else {
  209. console.log('user cancel')
  210. }
  211. }
  212. })
  213. }
  214. },
  215. /**
  216. * 页面相关事件处理函数--监听用户下拉动作
  217. */
  218. onPullDownRefresh: function() {
  219. setTimeout(() => {
  220. uni.stopPullDownRefresh()
  221. }, 200);
  222. },
  223. }
  224. </script>
  225. <style>
  226. .tui-addr-box {
  227. padding: 20rpx 0;
  228. }
  229. .tui-line-cell {
  230. width: 100%;
  231. padding: 24rpx 30rpx;
  232. box-sizing: border-box;
  233. display: flex;
  234. align-items: center;
  235. }
  236. .tui-title {
  237. width: 180rpx;
  238. font-size: 28rpx;
  239. flex-shrink: 0;
  240. }
  241. .tui-title-city-text {
  242. width: 180rpx;
  243. height: 40rpx;
  244. display: block;
  245. line-height: 46rpx;
  246. }
  247. .tui-input {
  248. width: 500rpx;
  249. }
  250. .tui-pr__30 {
  251. padding-right: 30rpx;
  252. }
  253. .tui-input-city {
  254. flex: 1;
  255. height: 40rpx;
  256. font-size: 28rpx;
  257. padding-right: 30rpx;
  258. }
  259. .tui-phcolor {
  260. color: #ccc;
  261. font-size: 28rpx;
  262. }
  263. .tui-cell-title {
  264. font-size: 28rpx;
  265. flex-shrink: 0;
  266. }
  267. .tui-addr-label {
  268. margin-left: 70rpx;
  269. }
  270. .tui-label-item {
  271. width: 76rpx;
  272. height: 40rpx;
  273. border: 1rpx solid rgb(136, 136, 136);
  274. border-radius: 6rpx;
  275. font-size: 26rpx;
  276. text-align: center;
  277. line-height: 40rpx;
  278. margin-right: 20rpx;
  279. display: inline-block;
  280. transform: scale(0.92);
  281. }
  282. .tui-label-active {
  283. background: #E41F19;
  284. border-color: #E41F19;
  285. color: #fff;
  286. }
  287. .tui-swipe-cell {
  288. width: 100%;
  289. display: flex;
  290. justify-content: space-between;
  291. align-items: center;
  292. background: #fff;
  293. padding: 10rpx 24rpx;
  294. box-sizing: border-box;
  295. border-radius: 6rpx;
  296. overflow: hidden;
  297. font-size: 28rpx;
  298. }
  299. .tui-switch-small {
  300. transform: scale(0.8);
  301. transform-origin: 100% center;
  302. }
  303. /* #ifndef H5 */
  304. .tui-switch-small .wx-switch-input {
  305. margin: 0 !important;
  306. }
  307. /* #endif */
  308. /* #ifdef H5 */
  309. >>>uni-switch .uni-switch-input {
  310. margin-right: 0 !important;
  311. }
  312. /* #endif */
  313. .tui-addr-save {
  314. padding: 24rpx 30rpx;
  315. margin-top: 100rpx;
  316. }
  317. .tui-del {
  318. padding: 24rpx 30rpx;
  319. }
  320. </style>